Syntax error for simple script

Steve D'Aprano steve+python at pearwood.info
Tue Jun 27 01:37:27 EDT 2017


On Tue, 27 Jun 2017 09:21 am, Stefan Ram wrote:

> Erik <python at lucidity.plus.com> writes:        Using 'print' as a
>>statement is obsolete syntax in Python 3.
> 
>   »print« never was a statement.


Of course it could be a statement, just like "y = x + 1" is a statement.

>   »print« was a keyword (2.7.6 2.3.1).

It can be both, depending on context.

>   What /was/ a statement in 2.7.6 was (2.7.6 6.6)
> 
> "print" ( [ expression ("," expression )* ["," ]]|
> ">>" expression [( "," expression )+ [ "," ]])

Which includes the case that print is called with no arguments:

print

which is a statement.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list