annotate Doc/ref/reswords.py @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents 515ed73da5b1
children 60415bf5f8f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5446
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 """Spit out the Python reserved words table."""
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 import string
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 raw_words = """
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 and del for is raise
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 assert elif from lambda return
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 break else global not try
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 class except if or while
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 continue exec import pass
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 def finally in print
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 """
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
13
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 ncols = 5
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
15
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 def main():
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 words = string.split(raw_words)
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 words.sort()
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 colwidth = 1 + max(map(len, words))
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 nwords = len(words)
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 nrows = (nwords + ncols - 1) / ncols
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 for irow in range(nrows):
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 for icol in range(ncols):
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 i = irow + icol * nrows
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 if 0 <= i < nwords:
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 word = words[i]
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 else:
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 word = ""
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 print "%-*s" % (colwidth, word),
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 print
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
31
515ed73da5b1 Tiny utility prints the latest set of reserved words.
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 main()