summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-05-08 23:21:48 (GMT)
committerGuido van Rossum <guido@python.org>1997-05-08 23:21:48 (GMT)
commit4408ed5dcb21cb0e76708a7c52297e92f66266ea (patch)
tree02593c78eb6e9514e02860eccd825c44fc60a1c1 /Doc
parent78b21cf47a53190381e2d02a67f3e0c2b908b286 (diff)
downloadcpython-4408ed5dcb21cb0e76708a7c52297e92f66266ea.zip
cpython-4408ed5dcb21cb0e76708a7c52297e92f66266ea.tar.gz
cpython-4408ed5dcb21cb0e76708a7c52297e92f66266ea.tar.bz2
Tiny utility prints the latest set of reserved words.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/ref/reswords.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/Doc/ref/reswords.py b/Doc/ref/reswords.py
new file mode 100644
index 0000000..22c3bb8
--- /dev/null
+++ b/Doc/ref/reswords.py
@@ -0,0 +1,32 @@
+"""Spit out the Python reserved words table."""
+
+import string
+
+raw_words = """
+and del for is raise
+assert elif from lambda return
+break else global not try
+class except if or while
+continue exec import pass
+def finally in print
+"""
+
+ncols = 5
+
+def main():
+ words = string.split(raw_words)
+ words.sort()
+ colwidth = 1 + max(map(len, words))
+ nwords = len(words)
+ nrows = (nwords + ncols - 1) / ncols
+ for irow in range(nrows):
+ for icol in range(ncols):
+ i = irow + icol * nrows
+ if 0 <= i < nwords:
+ word = words[i]
+ else:
+ word = ""
+ print "%-*s" % (colwidth, word),
+ print
+
+main()