[wxPython-users] Many Similar Dialogs For Date Entry
Paul Koning
pkoning at equallogic.com
Fri Feb 2 12:23:09 PST 2007
>>>>> "Rich" == Rich Shepard <rshepard at appl-ecosys.com> writes:
Rich> On Fri, 2 Feb 2007, Chris Mellon wrote:
>> Python lacks a case statement,
Rich> Tell me about it! I really miss the switch statement which my C
Rich> applications always use extensively.
>> Python with dictionary:
>>
>> def processID(id): mapper = { SWITCH_ONE:process_one,
>> SWITCH_TWO:process_two } mapper[id]()
If your inputs are strings of the right form (or can be turned into
such strings), you can use them to construct function (or method)
names directly:
def process(cmd):
action = globals().get("process_cmd_%s" % cmd)
if not action:
print "Invalid command"
return
action ()
paul
More information about the wxpython-users
mailing list