Guido van Rossum | 4408ed5 | 1997-05-08 23:21:48 +0000 | [diff] [blame] | 1 | """Spit out the Python reserved words table.""" |
| 2 | |
Guido van Rossum | 4ed6be7 | 2001-12-04 20:39:36 +0000 | [diff] [blame] | 3 | import keyword |
Guido van Rossum | 4408ed5 | 1997-05-08 23:21:48 +0000 | [diff] [blame] | 4 | |
| 5 | ncols = 5 |
| 6 | |
| 7 | def main(): |
Guido van Rossum | 4ed6be7 | 2001-12-04 20:39:36 +0000 | [diff] [blame] | 8 | words = keyword.kwlist[:] |
Guido van Rossum | 4408ed5 | 1997-05-08 23:21:48 +0000 | [diff] [blame] | 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() |