]> granicus.if.org Git - python/commitdiff
Temporary fix to valid_identifier().
authorGuido van Rossum <guido@python.org>
Tue, 7 Oct 1997 14:51:18 +0000 (14:51 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 7 Oct 1997 14:51:18 +0000 (14:51 +0000)
Lib/re.py

index 6c3ee0becf913d78f2d3e07d43bd0c5744179adf..b08f8af4c6ab9e6854c2f42b2ed76b3c45a9d4c5 100644 (file)
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -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={}