[Python-Dev] conditional expressions?

Guido van Rossum guido@python.org
Mon, 15 Oct 2001 16:14:48 -0400


[Paul]
> I know there's been a long time request for this feature,
> supposedly from people coming to Python from C,

or any other language -- it's in Java, Perl, C++, Icon, Haskell,
Lisp...  People have been arguing for years how to do this.

> but what's the real reason for adding it now,
> without even a PEP ?
> Does it really add enough to the language to justify the bloat ?

We'll see about the PEP (I think it's a good idea to motivate the
change).

The language bloat is very small IMO -- much less than augmented
assignment or list comprehensions, actually, and the benefits are
quite substantial, when used judiciously.  Like augmented assignment,
the conditional expression matches how I *think* about certain
situations; it's nice to finally be able to write them down right.
It's especially useful in function arguments, in string formatting
operations, or in lambdas (if you like lambdas :-).

--Guido van Rossum (home page: http://www.python.org/~guido/)