[Info] PEP 308 accepted - new conditional expressions
Reinhold Birkenfeld
reinhold-birkenfeld-nospam at wolke7.net
Sat Oct 1 02:30:25 EDT 2005
Sam wrote:
> Jaime Wyant writes:
>
>> On 9/30/05, Sam <sam at email-scan.com> wrote:
>>> Reinhold Birkenfeld writes:
>>>
>>> > Hi,
>>> >
>>> > after Guido's pronouncement yesterday, in one of the next versions of Python
>>> > there will be a conditional expression with the following syntax:
>>> >
>>> > X if C else Y
>>> >
>>> > which is the same as today's
>>> >
>>> > (Y, X)[bool(C)]
>>>
>>> What's wrong with "C ? X:Y"?
>>>
>>> Aside from ":" being overloaded?
>>>
>>
>> First thing that comes to my mind is that it is more C-ish (read
>> cryptic) than pythonic (read elegant and understandable).
>
> And "foo if bar" is Perl-ish; yet, even Perl has the ? : operators.
Perl's "foo if bar" is very different to this one, you should know about this.
For a conditional, syntax must be found, and the tradition of Python
design is not to use punctuation for something that can be solved with
keywords.
Reinhold
More information about the Python-list
mailing list