Mercurial > python-cmd2
comparison docs/pycon2010/pycon2010.rst @ 375:6cc12ad6e616
options in pirate8.py slide
author | cat@eee |
---|---|
date | Sat, 20 Feb 2010 09:26:33 -0500 |
parents | 89e38f922c25 |
children | 32b9137577b8 |
comparison
equal
deleted
inserted
replaced
374:89e38f922c25 | 375:6cc12ad6e616 |
---|---|
302 Options: pirate8.py | 302 Options: pirate8.py |
303 =================== | 303 =================== |
304 | 304 |
305 :: | 305 :: |
306 | 306 |
307 @options([make_option('--ho', type='int', default=2, | |
308 help="How often to chant 'ho'"), | |
309 make_option('-c', '--commas', | |
310 action="store_true", | |
311 help="Intersperse commas")]) | |
307 def do_yo(self, arg, opts): | 312 def do_yo(self, arg, opts): |
308 chant = ['yo'] + ['ho'] * opts.ho | 313 chant = ['yo'] + ['ho'] * opts.ho |
309 separator = ', ' if opts.commas else ' ' | 314 separator = ', ' if opts.commas else ' ' |
310 chant = separator.join(chant) | 315 chant = separator.join(chant) |
311 print('{0} and a bottle of {1}' | 316 print('{0} and a bottle of {1}' |