summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-10-07 14:51:18 (GMT)
committerGuido van Rossum <guido@python.org>1997-10-07 14:51:18 (GMT)
commitc6e8fd6de773ce7d9cc2013744e77067ccd04d21 (patch)
treea41dfdaafec64e1bdbf642d57a80581bfaa8c4ad
parent2f3941d743481ac48628b8b2c075f2b82762050b (diff)
downloadcpython-c6e8fd6de773ce7d9cc2013744e77067ccd04d21.zip
cpython-c6e8fd6de773ce7d9cc2013744e77067ccd04d21.tar.gz
cpython-c6e8fd6de773ce7d9cc2013744e77067ccd04d21.tar.bz2
Temporary fix to valid_identifier().
-rw-r--r--Lib/re.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/Lib/re.py b/Lib/re.py
index 6c3ee0b..b08f8af 100644
--- 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={}