Old Paranoia Game in Python
Terry Reedy
tjreedy at udel.edu
Mon Jan 10 16:02:24 EST 2005
Never saw this specific game. Some suggestions on additional factoring out
of duplicate code.
> def next_page(this_page):
> print "\n"
> if this_page == 0:
> page = 0
> return
The following elif switch can be replaced by calling a selection from a
list of functions:
[None, page1, pag2, ... page57][this_page]()
> elif this_page == 1:
> page1()
> return
> elif this_page == 2:
> page2()
> return
...
> elif this_page == 57:
> page57()
> return
Also, a chose3 function to complement your chose (chose2) function would
avoid repeating the choose-from-3 code used on multiple pages.
Terry J. Reedy
More information about the Python-list
mailing list