emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: python-mode: make sure output is not eaten


From: Ken Manheimer
Subject: Re: python-mode: make sure output is not eaten
Date: Fri, 25 Aug 2006 15:53:56 -0400

On 8/24/06, Steven Huwig <address@hidden> wrote:

On Aug 23, 2006, at 12:04 AM, Stefan Monnier wrote:
>
> Yes, of course.  BTW do you have any idea why the current code uses
> "\n\n"?

Might it be because the Python interactive interpreter needs the extra
newline due to significant whitespace?  E.g.

 >>> for i in range(1,5):
...     print i,
...
1 2 3 4

i haven't looked at the code in question, but have a salient point to
offer.  the handling of interactively entered python code is different
than the processing of source code from a file, specifically in that
the end of top-level blocks is detected by an empty line of input.

this is necessary because, during interaction, you don't want to
require people to enter the first line of the subsequent top-level
construct to determine that the previous top-level construct has
concluded.  instead, it's assumed they've concluded when an empty line
is encountered.

i suspect that the "\n\n" you all are referring to is specifically to
provide that newline.

a DEDENT token is created by the unindented second newline, closing
the block.  A single newline cannot do that as it is also the
statement terminator.

... and a double newline doesn't have this effect for file input,
where the interpreter/compiler *can* wait for the first line of the
next top-level construct, or end-of-file.

> [...]

--
ken
address@hidden
http://myriadicity.net




reply via email to

[Prev in Thread] Current Thread [Next in Thread]