diff options
author | Guido van Rossum <guido@python.org> | 1997-10-07 14:51:18 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-10-07 14:51:18 +0000 |
commit | 790f37b223492e481cd309225a9edd142a24ff41 (patch) | |
tree | 02f0642297d2a47709477ab00ee8876f70633c02 /Lib/re.py | |
parent | 8adda0624a445202da5512a6dbe6de0599f913e7 (diff) | |
download | cpython-790f37b223492e481cd309225a9edd142a24ff41.tar.gz |
Temporary fix to valid_identifier().
Diffstat (limited to 'Lib/re.py')
-rw-r--r-- | Lib/re.py | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -231,16 +231,15 @@ def escape(pattern): result.append(char) return string.join(result, '') +_idprog = None def valid_identifier(id): - import string - if len(id) == 0: - return 0 - if id[0] not in string.letters+'_': + global _idprog + if not _idprog: + _idprog = compile(r"[a-zA-Z_]\w*$") + if _idprog.match(id): + return 1 + else: return 0 - for char in id[1:]: - if not syntax_table[char] & word: - return 0 - return 1 def compile(pattern, flags=0): groupindex={} |