RE: ignoring blank lines in input

Michael McLay (mclay@eeel.nist.gov)
Fri, 27 May 94 08:36:56 EDT

tnb2d@henson.cs.virginia.edu writes:
> On my SparcStation I
> hit ctrl-d to end my interactive session. This has nothing to do with
> the language, it goes straight to the running process and does the
> right thing. Can't we implement something like ctrl-q (or whatever,
> as long as it's not alredy in use) that does this for terminating
> blocks?

This wouldn't be a problem if the interpreter didn't generate an error
for the following:

Python 1.0.1 (Feb 25 1994)
Copyright 1991-1994 Stichting Mathematisch Centrum, Amsterdam
>>> def foo():
... print 'x'
... print 'y'
...
>>> print 'z'
File "<stdin>", line 1
print 'z'
^
SyntaxError: invalid syntax
>>>

Why wasn't the interpreter able to recognize that the print 'z'
statement was suppose to be part of the def foo() block? I put a tab
before the print 'z' statement but this wasn't interpreted as an
INDENT. Instead Python complained about an invalid syntax. The blank
line would be ignored if it was parsed as input from a file. Why is
the interpreter different?

I hope Guido ignores this complaint and works on adding interesting
extensions to Python, such as persistence objects or access
protection. This quirk in the interpreter shouldn't really be a life
and death issue for Python users. The interpreter is a handy tool to
have around for doing quick calculations, but it isn't the only method
for interacting with the language. Code that is complicated enough to
require serious use of indentation can always be written using a text
editor. A scratch buffer in emacs is an easy way to execute a test
script. Ctrl-c Ctrl-c can be used to run the code without having to
save the test code to a temporary file.