nice python solution

Tim Daneliuk tundra at tundraware.com
Wed Nov 21 19:50:03 EST 2001


Uwe Schmitt wrote:
> 
> Hi,
> 
> i there a nice python shortcut for:
> 
>     if idx=0:
>        a=val
>     elif idx=1:
>        b=val
> 
>

<SNIP>

How about...

varlist = ["a", "b"]

... whatever code you need to get idx and val ready ...

exec varlist[idx] + "=val"


------------------------------------------------------------------------------
Tim Daneliuk
tundra at tundraware.com



More information about the Python-list mailing list