hash comments in interactive shell

John Belmonte john at neggie.net
Thu May 20 19:52:58 EDT 2004


Terry Reedy wrote:
> I believe I have seen this discussed either on clp or pydev.  As I
> remember, it is a side-effect of way interactive interpreter works, not
> intended, but apparently not as easy to change as it would seem.
> Perhaps someone else remembers more.

I've stumbled on some clues.  One is that compile() doesn't like full 
line hash comments:

   >>> compile('#foo', '(string)', 'single')
   Traceback (most recent call last):
     File "<stdin>", line 1, in ?
   TypeError: compile() takes at least 3 arguments (2 given)

Another is that code.interact (the interactive interpreter emulator) 
behaves as I want:

   >>> 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

I'd really like to make the real interpreter act like the emulator...

-John


-- 
http:// ift ile.org/




More information about the Python-list mailing list