Guido van Rossum | 4408ed5 | 1997-05-08 23:21:48 +0000 | [diff] [blame] | 1 | """Spit out the Python reserved words table.""" |
| 2 | |
| 3 | import string |
| 4 | |
| 5 | raw_words = """ |
| 6 | and del for is raise |
| 7 | assert elif from lambda return |
| 8 | break else global not try |
| 9 | class except if or while |
| 10 | continue exec import pass |
| 11 | def finally in print |
| 12 | """ |
| 13 | |
| 14 | ncols = 5 |
| 15 | |
| 16 | def main(): |
| 17 | words = string.split(raw_words) |
| 18 | words.sort() |
| 19 | colwidth = 1 + max(map(len, words)) |
| 20 | nwords = len(words) |
| 21 | nrows = (nwords + ncols - 1) / ncols |
| 22 | for irow in range(nrows): |
| 23 | for icol in range(ncols): |
| 24 | i = irow + icol * nrows |
| 25 | if 0 <= i < nwords: |
| 26 | word = words[i] |
| 27 | else: |
| 28 | word = "" |
| 29 | print "%-*s" % (colwidth, word), |
| 30 | print |
| 31 | |
| 32 | main() |