summaryrefslogtreecommitdiffstats
path: root/Lib/keyword.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-10-22 21:00:49 (GMT)
committerGuido van Rossum <guido@python.org>1997-10-22 21:00:49 (GMT)
commit9694fcab5332f27dc28b195ba1391e5491d2eaef (patch)
tree23dc3d9a7d1cc4b138ac2bffd028a519cba93b30 /Lib/keyword.py
parent426916e50e1209d8ecc12678855dc531863a48c5 (diff)
downloadcpython-9694fcab5332f27dc28b195ba1391e5491d2eaef.zip
cpython-9694fcab5332f27dc28b195ba1391e5491d2eaef.tar.gz
cpython-9694fcab5332f27dc28b195ba1391e5491d2eaef.tar.bz2
Convert all remaining *simple* cases of regex usage to re usage.
Diffstat (limited to 'Lib/keyword.py')
-rwxr-xr-xLib/keyword.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/keyword.py b/Lib/keyword.py
index 2ad80d7..ba9249d 100755
--- a/Lib/keyword.py
+++ b/Lib/keyword.py
@@ -7,10 +7,7 @@
# To update the symbols in this file, 'cd' to the top directory of
# the python source tree after building the interpreter and run:
#
-# PYTHONPATH=./Lib ./python Lib/keyword.py
-#
-# (this path allows the import of string.py and regexmodule.so
-# for a site with no installation in place)
+# python Lib/keyword.py
kwlist = [
#--start keywords--
@@ -52,7 +49,7 @@ for keyword in kwlist:
iskeyword = kwdict.has_key
def main():
- import sys, regex, string
+ import sys, re, string
args = sys.argv[1:]
iptfile = args and args[0] or "Python/graminit.c"
@@ -61,13 +58,15 @@ def main():
# scan the source file for keywords
fp = open(iptfile)
- strprog = regex.compile('"\([^"]+\)"')
+ strprog = re.compile('"([^"]+)"')
lines = []
while 1:
line = fp.readline()
if not line: break
- if string.find(line, '{1, "') > -1 and strprog.search(line) > -1:
- lines.append(" '" + strprog.group(1) + "',\n")
+ if string.find(line, '{1, "') > -1:
+ match = strprog.search(line)
+ if match:
+ lines.append(" '" + match.group(1) + "',\n")
fp.close()
lines.sort()
@@ -90,4 +89,5 @@ def main():
fp.write(string.join(format, ''))
fp.close()
-if __name__ == "__main__": main()
+if __name__ == "__main__":
+ main()