something like "if" that returns a value?
Paul Rudin
Paul_Rudin at scientia.com
Mon Nov 11 10:18:52 EST 2002
>>>>> "hk" == holger krekel <pyth at devel.trillke.net> writes:
hk> Paul Rudin wrote:
>> - potentially both y and z are evaluated; and
hk> no. more precisely, only
hk> if x is true and y is false is z also considered.
I said "potentially" - so we're agreeing - there are circumstances in
which both y and z have to be evaluated. Sometimes this might not
matter, others it could be very significant.
>> - there's a degree of obfuscation here, the code is less
>> comprehensible than something like: if x then y else z.
hk> IMO it's not overly hard to get used to it. It certainly isn't as
hk> evident (as has the aforementioned pitfall) as in some other
hk> languages. Funny enough, i don't need this ternary operation
hk> often.
hk> And if one the expressions is more complex i use a proper
hk> if-clause.
I guess these things depend on what you're used to - I now program
mostly in lisp; I used to program mostly in c++; I'm very used to
using such a construct. Using an if-then-else type construct without a
return value makes some code rather inelegant, it seems to me. But no
doubt one can get used to it.
--
Were these parsnips CORRECTLY MARINATED in TACO SAUCE?
More information about the Python-list
mailing list