summaryrefslogtreecommitdiff
path: root/docs/pycon2010/pirate2.py
blob: 343f94fff3dd55803046fcb52c65c7aa1a776174 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# coding=utf-8
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()