On Fri, 30 May 2014 10:46:34 +1000, Chris Angelico wrote:

> On Fri, May 30, 2014 at 10:33 AM, Steven D'Aprano
> <steve+comp.lang.pyt...@pearwood.info> wrote:
>> (By the way, ; won't work for a Python shell, because ;spam already is
>> valid Python syntax: it's an empty statement followed by the statement
>> spam, separated by a semicolon.)
> That's not really a problem, though. It's not going to stop you from
> doing something actually *useful*, and the fact that the semicolon could
> be syntactically valid isn't going to come into it, because the REPL
> would swallow it anyway.

The point is that *syntactically valid* Python statements should not 
behave differently when running inside the shell or not. I thought 
that ;statement was syntactically valid -- but I was wrong. The vanilla 
CPython interactive interpreter gives a syntax error, as do IronPython 
and Jython. I misinterpreted what I saw in IPython -- it's already doing 
magic at the command line:

In [4]: len []
------> len([])
Out[4]: 0

In [5]: ;len []
------> len("[]")
Out[5]: 2

Steven D'Aprano

Reply via email to