[Python-Dev] odd interpreter feature

Skip Montanaro skip@pobox.com
Wed, 7 May 2003 11:15:35 -0500


    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.

Skip