[Python-Dev] odd interpreter feature

Sjoerd Mullender sjoerd@acm.org
Thu, 08 May 2003 10:11:15 +0200


Isn't it the case that you should only get a secondary prompt after the
comment line if the comment line *itself* had a secondary prompt?

On Wed, May 7 2003 Skip Montanaro wrote:

> 
>     Guido> Please do.  The indentation level should be easily available,
>     Guido> since it is computed by the tokenizer.
> 
> Alas, it's more complicated than just the indentation level of the current
> line.  I need to know if the previous line was indented, which I don't think
> the tokenizer knows (at least examining *tok in gdb under various conditions
> suggests it doesn't).
> 
> I see the following possible cases (there are perhaps more, but I think they
> are similar enough to ignore here):
> 
>     >>> if x == y:
>     ...   # hello
>     ...   pass
>     ... 
>     >>> if x == y:
>     ...   x = 1
>     ... # hello
>     ...   pass
>     ... 
>     >>> x = 1
>     >>> # hello
>     ... 
>     >>> 
> 
> Only the last case should display the primary prompt after the comment is
> entered.  The other two correctly display the secondary prompt.  It's
> distinguishing the second and third cases in the tokenizer without help from
> the parser that's the challenge.
> 
> Oh well.  Perhaps it's a wart best left alone.

-- Sjoerd Mullender <sjoerd@acm.org>