Congragulations heartily given. I missed the ternary op in c... Way to go! clean and easy and now i can do: if ((sys.argv[1] =='debug') if len(sys.argv) > 1 else False): pass and check variables IF AND ONLY if they exist, in a single line! but y'all knew that..
On Sat, Oct 08, 2005 at 08:04:13PM -0400, jamesr wrote:
if ((sys.argv[1] =='debug') if len(sys.argv) > 1 else False): pass
Very good example! Very good example why ternary operators must be forbidden! Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
Andrew> Umm... Is this a joke? I hope so. I must admit the OP's intent didn't make itself known to me with the cursory glance I gave it. Jp's formulation is how I would have written it. Assuming of course, that was the OP's intent. Skip
On Sat, 8 Oct 2005 20:04:13 -0400, jamesr <circlecycle@gmail.com> wrote:
Congragulations heartily given. I missed the ternary op in c... Way to go! clean and easy and now i can do:
if ((sys.argv[1] =='debug') if len(sys.argv) > 1 else False): pass
and check variables IF AND ONLY if they exist, in a single line!
if len(sys.argv) > 1 and sys.argv[1] == 'debug': ... usually-wouldn't-but-can't-pass-it-up-ly y'rs, Jp
jamesr wrote:
Congragulations heartily given. I missed the ternary op in c... Way to go! clean and easy and now i can do:
if ((sys.argv[1] =='debug') if len(sys.argv) > 1 else False): pass
and check variables IF AND ONLY if they exist, in a single line!
but y'all knew that..
Yep, it was a conscious decision to add a construct with the *potential* to be abused for use in places where the existing "and" and "or" expressions *are* being abused and resulting in buggy code. The code in your example is lousy because it's unreadable (and there are far more readable alternatives like a simple short-circuiting usage of "and"), but at least it's semantically correct (whereas the same can't be said for the current abuse of "and" and "or"). If code using a conditional expression is unclear, blame the programmer for choosing to write the code, don't blame the existence of the conditional expression :) We're-all-adults-here-ly yours, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia --------------------------------------------------------------- http://boredomandlaziness.blogspot.com
participants (6)
-
Andrew Koenig -
jamesr -
Jp Calderone -
Nick Coghlan -
Oleg Broytmann -
skip@pobox.com