[Python-Dev] Adding a conditional expression in Py3.0

Michael Hudson mwh at python.net
Wed Sep 21 12:10:37 CEST 2005

Guido van Rossum <guido at python.org> writes:

>> Given the later addition of generator expressions with mandatory
>> parentheses , the mandatory-parentheses version of a conditional expression
>> looks less strange to me than it did then ;-).  So I could happily use it
>> even though I may still lean toward the other option 2 version (then-else)
>> due to  its not needing ':'s or a third elseif term for chaining.
> I think I'd prefer (if <expr> then <expr> else <expre>) i.e. no
> colons. 

My problem with this syntax is that it can be hard to read:

return if self.arg is None then default else self.arg

looks worryingly like


to me.

> None of the other expression forms (list comprehensions and
> generator expressions) involving statement keywords use colons.

This is also true.

>> *If* you want general community input, I would suggest a runoff ballot with
>> those four choices (and a summary of pros and cons of each), or fewer if
>> you see any as unacceptible.
> If there's one thing I've learned from the PEP 308 vote, it is that
> votes for language don't work. I prefer some discussion on Python-dev
> after which I pick one.

Well, this is my input (and now I'm going to try and stay out of it).


59. In English every word can be verbed. Would that it were so in
    our programming languages.
  -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html

More information about the Python-Dev mailing list