[Guido] > > Let me give you what you expect. If all the "X if C else Y" syntax > > does is prevent that atrocity from ever being introduced, it would be > > worth it. :)
[Steve] > Well, fine. However, it does allow atrocities like > > func(f for f in lst if f > -1 if f < 0 else +1) No it doesn't! Inside an 'if' (of any flavor), further ifs have to be nested. So you'd have to write func(f for f in lst if f > (-1 if f < 0 else +1)) or perhaps func(f for f in lst if (f > -1 if f < 0 else +1)) But I doubt you meant to write +1 where True could have sufficed. :) An if-else expression has lower priority than anything else except lambda; the expression lambda x: x if x >= 0 else -x is equivalent to lambda x: (x if x >= 0 else -x) > I realise that any chosen syntax is subject to abuse, but a conditional > expression in a (currently allowed) conditional context will be > guaranteed obscure. Your original instinct to omit conditional > expressions was right! Now you've pushed me over the edge. I've made up my mind now, "X if C else Y" it will be. I hope to find time to implement it in Python 2.5. Let it be as controversial as bool or @decorator, I don't care. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com