Printing of individually returned values when running interactively

Hrvoje Niksic hniksic at
Tue Nov 2 10:41:03 EST 1999

I've just noticed (the hard way) a very unusual feature of Python's
interactive interpreter mode.  If you evaluate several values on
several lines, all the values are printed!  For instance:

>>> if 1:
...  1
...  2
...  3

My remark will probably look strange to seasoned Pythoneers, but I'm
really surprised by discovering this.  Why would anyone want a thing
like that?  Doesn't it produce loads of debug-like output when pasting
more complex things?

I guess I'm more used to Lisp interactive interpreters whose REPL is
sexp-oriented, and prints the value of the last read sexp.

(If you're curious, the case that hit me hard was when I tested
mxODBC's connection with a remote database at work.  I wrote something

for i in range(10000):
  cur.execute('insert into test ...', i)

Needless to mention, the execute() method returns a number!)

More information about the Python-list mailing list