1997-05-08 23:21:48 +00:00
|
|
|
"""Spit out the Python reserved words table."""
|
|
|
|
|
2001-12-04 20:39:36 +00:00
|
|
|
import keyword
|
1997-05-08 23:21:48 +00:00
|
|
|
|
|
|
|
ncols = 5
|
|
|
|
|
|
|
|
def main():
|
2001-12-04 20:39:36 +00:00
|
|
|
words = keyword.kwlist[:]
|
1997-05-08 23:21:48 +00:00
|
|
|
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()
|