blob: e2c49609fc3124eee45058f4158398c04b835cac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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()
|