Conditional Expressions don't solve the problem

Guido van Rossum guido at
Tue Oct 16 19:46:56 CEST 2001

Dale Strickland-Clark <dale at> writes:

> I'm a bit mystified by all the activitiy on conditional expressions
> that appears to have originated from a post a while ago about curious
> assignment behaviour.
> Have I missed something here (quite possible) or are the two issues
> related? Because it doesn't seem so to me.
> The original discussion went on to talk about the loop and a half
> problem which sumarised it quite nicely for me.
> How does the if/then/else construct help me here?

It doesn't.

But it's a good thing you mentioned this, because it gives me the
opportunity to elaborate on some of my language design sensibilities.

I find a conditional expression useful IN SOME CASES where the
requirement to use a separate if statement and a temporary variable
interrupt the thought process of a human reader trying to understand
the code.

On the other hand, the ability to hide an assignment inside an
expression is IMO purely a way to save some keystrokes: the variable
needs to be named anyway, so you may as well do the assignment in a
separate step so that the reader is alerted of it.

That said, I'm still looking for decent examples of places in the
standard library that would become more readable with a conditional
expression...  Without more motivation, I think I'll hold back.

--Guido van Rossum (home page:

More information about the Python-list mailing list