| Line | |
|---|
| 1 | """Spit out the Python reserved words table."""
|
|---|
| 2 |
|
|---|
| 3 | import keyword
|
|---|
| 4 |
|
|---|
| 5 | ncols = 5
|
|---|
| 6 |
|
|---|
| 7 | def main():
|
|---|
| 8 | words = keyword.kwlist[:]
|
|---|
| 9 | words.sort()
|
|---|
| 10 | colwidth = 1 + max(map(len, words))
|
|---|
| 11 | nwords = len(words)
|
|---|
| 12 | nrows = (nwords + ncols - 1) / ncols
|
|---|
| 13 | for irow in range(nrows):
|
|---|
| 14 | for icol in range(ncols):
|
|---|
| 15 | i = irow + icol * nrows
|
|---|
| 16 | if 0 <= i < nwords:
|
|---|
| 17 | word = words[i]
|
|---|
| 18 | else:
|
|---|
| 19 | word = ""
|
|---|
| 20 | print "%-*s" % (colwidth, word),
|
|---|
| 21 | print
|
|---|
| 22 |
|
|---|
| 23 | main()
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.