source:
trunk/essentials/dev-lang/python/Doc/ref/reswords.py@
3951
| Last change on this file since 3951 was 3225, checked in by , 19 years ago | |
|---|---|
| File size: 515 bytes | |
| 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 | |
| 22 | |
| 23 | main() |
