Switch statements again
Skip Montanaro
skip at pobox.com
Wed Jan 15 18:13:15 EST 2003
Steven> I've been reading the claims about doing things a more elegant
Steven> way in python when it comes to switch statements, using
Steven> if-elif-else and/or dictionaries of function pointers. the
Steven> following can be done with if-elif-else (and that's how I did
Steven> it), but it sure is ugly. my question is simply "what's the
Steven> best way to do this in python?"
If/elif/else remains the most common method. If Python ever gains something
like a switch statement you can bet the farm it won't have a "fall thru"
feature though, so the way you've coded your C switch statement wouldn't
work.
Skip
More information about the Python-list
mailing list