nice python solution
Chris Tavares
christophertavares at earthlink.net
Sun Nov 18 23:08:55 EST 2001
"Daniel Klein" <danielk at aracnet.com> wrote in message
news:eoigvt0jf0jqgt15et5o61nomh27f0mp7j at 4ax.com...
> Why not assign the most likely value and then test for the other, ie
>
> a = val
> if idx = 1:
> b = val
>
> Daniel Klein
Actually, that has different semantics. What you'd need is:
a = val
if idx == 1: # Note the typo - should be ==, not =
b = val
del a # <--- need this to match original version
To be honest, I'd prefer the original - it's easier to read and more
straightforward. I'm a bit curious what the original poster wanted to do -
these kind of constructions are almost always done better some other way.
-Chris
More information about the Python-list
mailing list