Show More
@@ -46,13 +46,10 b' lines = [line_to_tuple(line) for line in lines]' | |||
|
46 | 46 | print('Filtering out characters that are not valid Python 3 identifiers') |
|
47 | 47 | |
|
48 | 48 | def test_ident(i): |
|
49 |
"""Is the unicode string |
|
|
50 | try: | |
|
51 | exec('a%s = 10' % i, {}, {}) | |
|
52 | except SyntaxError: | |
|
53 | return False | |
|
54 | else: | |
|
55 | return True | |
|
49 | """Is the unicode string valid in a Python 3 identifer.""" | |
|
50 | # Some characters are not valid at the start of a name, but we still want to | |
|
51 | # include them. So prefix with 'a', which is valid at the start. | |
|
52 | return ('a' + i).isidentifier() | |
|
56 | 53 | |
|
57 | 54 | assert test_ident("α") |
|
58 | 55 | assert not test_ident('‴') |
General Comments 0
You need to be logged in to leave comments.
Login now