summaryrefslogtreecommitdiffstats
path: root/Lib/keyword.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/keyword.py')
-rwxr-xr-xLib/keyword.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/Lib/keyword.py b/Lib/keyword.py
index a7abe2b..a3788a6 100755
--- a/Lib/keyword.py
+++ b/Lib/keyword.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Keywords (from "graminit.c")
@@ -61,21 +61,19 @@ def main():
else: optfile = "Lib/keyword.py"
# scan the source file for keywords
- fp = open(iptfile)
- strprog = re.compile('"([^"]+)"')
- lines = []
- for line in fp:
- if '{1, "' in line:
- match = strprog.search(line)
- if match:
- lines.append(" '" + match.group(1) + "',\n")
- fp.close()
+ with open(iptfile) as fp:
+ strprog = re.compile('"([^"]+)"')
+ lines = []
+ for line in fp:
+ if '{1, "' in line:
+ match = strprog.search(line)
+ if match:
+ lines.append(" '" + match.group(1) + "',\n")
lines.sort()
# load the output skeleton from the target
- fp = open(optfile)
- format = fp.readlines()
- fp.close()
+ with open(optfile) as fp:
+ format = fp.readlines()
# insert the lines of keywords
try: