diff options
Diffstat (limited to 'docs/pycon2010/pirate2.py')
-rw-r--r-- | docs/pycon2010/pirate2.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/pycon2010/pirate2.py b/docs/pycon2010/pirate2.py new file mode 100644 index 0000000..e2c4960 --- /dev/null +++ b/docs/pycon2010/pirate2.py @@ -0,0 +1,18 @@ +from cmd import Cmd +# using ``do_`` methods + +class Pirate(Cmd): + gold = 3 + def do_loot(self, arg): + 'Seize booty from a passing ship.' + self.gold += 1 + print('Now we gots {0} doubloons' + .format(self.gold)) + def do_drink(self, arg): + 'Drown your sorrrows in rrrum.' + self.gold -= 1 + print('Now we gots {0} doubloons' + .format(self.gold)) + +pirate = Pirate() +pirate.cmdloop() |