Mercurial > python-cmd2
annotate docs/pycon2010/pirate2.py @ 438:a5f3d5a89d6c tip
pyparsing 2.0.0 only if on Python3
author | Catherine Devlin <catherine.devlin@gmail.com> |
---|---|
date | Tue, 19 Feb 2013 04:33:12 -0500 |
parents | 89e38f922c25 |
children |
rev | line source |
---|---|
337 | 1 from cmd import Cmd |
2 # using ``do_`` methods | |
3 | |
4 class Pirate(Cmd): | |
351 | 5 gold = 3 |
337 | 6 def do_loot(self, arg): |
351 | 7 'Seize booty from a passing ship.' |
337 | 8 self.gold += 1 |
374 | 9 print('Now we gots {0} doubloons' |
10 .format(self.gold)) | |
337 | 11 def do_drink(self, arg): |
12 'Drown your sorrrows in rrrum.' | |
13 self.gold -= 1 | |
374 | 14 print('Now we gots {0} doubloons' |
15 .format(self.gold)) | |
337 | 16 |
17 pirate = Pirate() | |
374 | 18 pirate.cmdloop() |