annotate Demo/scripts/beer.py @ 54294:dba767bc3155 legacy-trunk

remove mention of old ctypes version
author Benjamin Peterson <benjamin@python.org>
date Sat, 23 May 2009 20:59:09 +0000
parents 272eccc573e2
children 34999a1aea9b 7d16b42fcdbd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9669
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 #! /usr/bin/env python
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 # By GvR, demystified after a version by Fredrik Lundh.
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 import sys
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 n = 100
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 if sys.argv[1:]: n = int(sys.argv[1])
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 def bottle(n):
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 if n == 0: return "no more bottles of beer"
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 if n == 1: return "one bottle of beer"
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 return str(n) + " bottles of beer"
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 for i in range(n):
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 print bottle(n-i), "on the wall,"
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 print bottle(n-i) + "."
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 print "Take one down, pass it around,"
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 print bottle(n-i-1), "on the wall."