On Fri, May 30, 2014 at 9:27 PM, Steven D'Aprano
> This is why I'm so adamant that, while REPLs may be permitted to
> introduce *new* syntax which is otherwise illegal to the Python parser,
> (e.g. like IPython's %magic and !shell commands) they *must not* change
> the meaning of otherwise legal Python syntax. It's simply a bad idea to
> have legal Python code mean different things depending on what
> environment you're running it in.
Hmm. I'm not sure that "raises SyntaxError" is any less a part of the
language's promise than "evaluates to twice the value of x" is. Would
you, for instance, permit the REPL to define a new __future__
directive, on the basis that it's invalid syntax currently?
>>> from __future__ import magic_command_history
SyntaxError: future feature magic_command_history is not defined
I don't think SyntaxError equates to "invitation to make changes".
>>> for i in range(5): i*3+2
If you do this in a script, it's perfectly legal, but won't print
anything. So the REPL is already "chang[ing] the meaning of otherwise
legal Python syntax", and what's more, it's making None into a special
>>> for i in range(5): None if i%2 else i
Practicality beats purity. If it's more useful to the end user for
something valid-but-illogical to have a new bit of meaning in
interactive mode, I say go for it.