Antoon said:
1) Only in an interactive environment.
True, I wanted to add that but forgot it. Doesn't change what I'm saying
though.
2) That the semantics differ according to where the expression is
used doesn't make a difference. That an expression decides which
branch of an if statement is executed or what object is pass
as an argument in a call are also semantic difference, yet
we still have an expression in both cases.
In both cases we have an expression, in both cases we have a statement,
in both cases the expression is a part of the statement. In one case the
expression is the only statement, in the other case the statement has
other parts too.
If you change the syntax, of course you will change the strings
that will be accepted. I could change the syntax to:
if_stmt ::= "if" "ifexpr" expression ...
Have I now proved that expressions after an if are not normal
expressions?
No, you still have a statement with one or more parts, one of which is
an expression.
In OOP terms: I think that an expression statement 'has an' expression
(I agree that is a very thin wrapper though), not that an expression
statement 'is an' expression.
But that was not the implication of what Guido supposedly had said.
So that this is not the case doesn't counter what I said.
Whether statements can be used in the place of expressions is indeed not
relevant to the discussion.
Regarding what Guido apparently said:
Antoon said:
> Well, it seems that Guido is wrong then. The documentation clearly
> states that an expression is a statement.
I don't think it says that at all.
> More specifically, everywhere you can use a statement, you can
> simply use an expression according to the python syntax.
If you use an expression where a statement is expected, you really
write an expression statement that contains the expression (and nothing
else, but that doesn't matter).