[Python-ideas] Statements vs Expressions... why?

Cesare Di Mauro cesare.dimauro at a-tono.com
Sun Sep 14 01:24:48 CEST 2008

> On Sat, 2008-09-13 at 23:58, Cliff Wells wrote:

> I understand that any such change would need to be adequately defined.
> But I don't consider the discussion to have progressed to that point.
> If people do not even understand that expression-oriented languages
> provide any advantage (in fact, many of them apparently consider it a
> disadvantage), then there's little point in discussing what particular
> syntax this apparently useless change would take on.

Are you sure that calculating and returning a value for each statement
that is interpreted as an expression is really an advantage? I find little
cases that shows such an advantage on real world code (one of each is the
ternary operator, that was introduced in Python 2.5 to fill that "hole").

Just to be clear, I think that returning a value after executing a for,
while, and even an if statement/expression EVERY TIME would be of no
pratical use except for very rare cases.

Consider that you have to spend resources (CPU and memory) calculating
values, that most of the time will be trashed because they will not be

I know that we already have functions that work the same way: they always
return something, defaulting to None when no return statement is used.
That's because Python has only a "function" type (contrary to Pascal,
which distinguish between functions and procedures), but I think that
Guido opted to reduce the complexity of the language giving just one
subroutine invocation type to use.

Do we really need to slow down the language (at the cost of less
readability too, because I'm strongly convinced that using statements like
expressions will reduce it) for such limited "added value"?

My 2 cents.

More information about the Python-ideas mailing list