[Python-Dev] Re: switch statement
Shane Hathaway
shane at hathawaymix.org
Wed Apr 27 23:54:31 CEST 2005
Michael Chermside wrote:
> if x == 1: | if condition_1:
> do_1() | y = 1
> elif x == 2: | elif condition_2:
> do_2() | y = 2
> elif x == 3: | elif condition_3:
> do_3() | y = 3
> else: | else:
> default() | y = 4
This inspired a twisted thought: if you just redefine truth, you don't
have to repeat the variable. <0.9 wink>
True = x
if 1:
do_1()
elif 2:
do_2()
elif 3:
do_3()
else:
default()
Shane
More information about the Python-Dev
mailing list