nice python solution

Chris Tavares christophertavares at
Mon Nov 19 05:08:55 CET 2001

"Daniel Klein" <danielk at> wrote in message
news:eoigvt0jf0jqgt15et5o61nomh27f0mp7j at
> 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.


More information about the Python-list mailing list