[Python-Dev] odd interpreter feature

Guido van Rossum guido@python.org
Wed, 07 May 2003 11:02:21 -0400


> I was editing the tutorial just now and noticed the secondary prompt (...)
> in a situation where I didn't think it was appropriate:
> 
>     >>> # The argument of repr() may be any Python object:
>     ... repr(x, y, ('spam', 'eggs'))
>     "(32.5, 40000, ('spam', 'eggs'))"
> 
> It's caused by the trailing colon at the end of the comment.  I verified it
> using current CVS:
> 
>     >>> hello = 'hello, world\n' hellos = repr(hello) print hellos
>     'hello, world\n'
>     >>> # hello:
>     ...
>     >>>
> 
> Shouldn't the trailing colon be ignored in comments?  Bug, feature or wart?

It's not the trailing colon.  Any line that consists of only a comment
does this:

  >>> 
  >>> # foo
  ... 
  >>>  # foo
  ...    
  >>> 12 # foo
  12
  >>> 

And yes, it's a wart, but I don't know how to fix it.

--Guido van Rossum (home page: http://www.python.org/~guido/)