[Python-Dev] Adding a conditional expression in Py3.0
Steve Holden
steve at holdenweb.com
Thu Sep 29 23:32:06 CEST 2005
Guido van Rossum wrote:
> On 9/29/05, Steve Holden <steve at holdenweb.com> wrote:
>
>>I would argue for mandatory parentheses around the expression, leaving
>>room later (probably after Guido is no longer around to be sick at the
>>site of it) for:
>>
>>def f(condition):
>> return something if condition # no else!
>> return somethingElse
>>
>>not-expecting-this-to-fly-ly y'rs - steve
>
>
> 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. :)
>
Well, fine. However, it does allow atrocities like
func(f for f in lst if f > -1 if f < 0 else +1)
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!
far-too-late-ly y'rs - steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/
More information about the Python-Dev
mailing list