nice python solution
Magnus Lie Hetland
mlh at idi.ntnu.no
Mon Nov 19 00:43:47 CET 2001
"Uwe Schmitt" <uwe at rocksport.de> wrote in message
news:9t95gu$ab7l1$1 at hades.rz.uni-sb.de...
> i there a nice python shortcut for:
> if idx=0:
> elif idx=1:
This isn't really an answer to your question, perhaps, but have
you considered keeping the if-sentence? It's a very Pythonic and
readable thing to do, IMO. Trying to find fancy shortcuts will
often make your code less readable, although possibly more
> I tried
> (a,b)[idx] = val
> but this does not work, i get an error message.
Well... If you want an evil solution:
locals()[['a','b'][idx]] = val
> Greetings, Uwe.
> Dr. Uwe Schmitt Uwe.Schmitt at num.uni-sb.de
Magnus Lie Hetland The Anygui Project
More information about the Python-list