Using rotor.py module
Terry Reedy
tjreedy at udel.edu
Wed Nov 15 21:48:47 EST 2000
> # LICENSE: HACK IT AS YOU LIKE AND EVEN DISTRIBUTE IT IF YOU WANT
BUT
> PLEASE KEEP
> # THESE LINES OF COMMENT INTACT
Including all-caps shouting and note about buggyness?
> a = input ("Choose: ")
recommend raw_input("Choose: ") -- its safer and number not needed
> if a == 1:
> CryptFile()
> elif a == 2:
> DecryptFile()
> elif a == 3:
> readCypher()
> elif a == 4:
> readDecypher()
> elif a == 5:
> writeMess()
> elif a == 6:
> raw_input ("Hit Return to Exit...")
Switches can also be done with a dictionary:
_menu_func = { # outside function
'1':CryptFile,
'2': DecryptFile,
'3': readCypher,
'4': readDecypher,
'5':writeMess,
'6': (lambda :raw_input ("Hit Return to Exit..."))
}
and within function, just call
_menu_func[a]()
More information about the Python-list
mailing list