
Hello,
I'm wondering what the rationale is for hash comments yielding a continuation prompt (PS2) in the interactive interpreter. I'd like to put such comments in interactive examples, but the output is hard to follow:
a = 5 # and now for some multiplication
...
a * 10
50
What I would prefer can, ironically, be shown by the interactive interpreter emulator:
import code code.interact()
Python 2.3.3 (#2, May 1 2004, 06:12:12) [GCC 3.3.3 (Debian 20040401)] on linux2 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole)
a = 5 # and now for some multiplication a * 10
50
Another apparent inconsistency is that end of line comments don't behave this way:
a = 5 a * 10 # end of line comment
50
Is there something preventing this anomaly in the interactive interpreter from being corrected?
-John

John Belmonte john@neggie.net writes:
Hello,
I'm wondering what the rationale is for hash comments yielding a continuation prompt (PS2) in the interactive interpreter. I'd like to put such comments in interactive examples, but the output is hard to follow:
[...]
Is there something preventing this anomaly in the interactive interpreter from being corrected?
Lack of time and effort? The parser is fairly hairy.
Cheers, mwh

I'm wondering what the rationale is for hash comments yielding a continuation prompt (PS2) in the interactive interpreter. I'd like to put such comments in interactive examples, but the output is hard to follow:
a = 5 # and now for some multiplication
...
a * 10
50
It's a bug -- but not easy to fix or it would have been fixed long ago. Probably the lexter could be hacked to fix this, but be careful that a change doesn't botch all the other special cases!
--Guido van Rossum (home page: http://www.python.org/~guido/)
participants (3)
-
Guido van Rossum
-
John Belmonte
-
Michael Hudson