3 ms·
that's fixed in python 3 [edit: sorry, yes, i agree the general problem remains.]
by andrewcooke 16y ago
that's fixed in python 3
[edit: sorry, yes, i agree the general problem remains.]
- bajsejohannes 16y agoFor the specific example of print, then yes. But in general it is not. Another example is if-statements in python: >>> x=if True: File "<stdin>", line 1 x=if True: ^ SyntaxError: invalid syntax whereas in Ruby: >> x=if true: ?> 5 >> end => 5 Other Python statements from the top of my head: for, while, def, import. My point is that there absolutely are statements that are not expressions in Python. (You can easily tell by trying to assign the return value: x=<statement>).
- kbd 16y agoHeck, assignment itself is a statement. That's why you can't say while x=y: ... (and you'll notice the REPL gives no return value for an assignment). This "Python has no statements" error was one of my biggest annoyances with this article, as Python has a very strong statement vs expression dichotomy.
- deleted 16y ago[deleted]