[IPython-user] Prompt expressions

Michael Scarpa m.scarpa at uva.nl
Tue Jun 13 06:50:00 CDT 2006

Dear IPython users,

I just noticed that prompt expressions seem to be evaluated *twice* in
IPython.  I have upgraded to the freshly released 0.7.2 but the
phenomenon still occurs.  Here's an example on how to replicate this
(quick and dirty):

In ~/.ipython/ipythonrc replace

prompt_in1 'In [\#]: '


execute def say():print "hello"
prompt_in1 'In [\#]{$say()}: '

Now run ipython:

$ ipython
Python 2.4.1 (#1, Oct 11 2005, 13:14:03)
Type "copyright", "credits" or "license" for more information.

IPython 0.7.2 -- An enhanced Interactive Python.
?       -> Introduction to IPython's features.
%magic  -> Information about IPython's 'magic' % functions.
help    -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]{None}: 

In [1]{None}:

The above is the output on my machine.  For clarity, I pressed enter
(without other input) at the prompt to get the prompt to be printed
again, which shows how the function is indeed called twice every time.

Am I doing something wrong?  Is this a feature of IPython?  And most
importantly (to me): how can I avoid this?  Of course I could keep
flipping a bit in the method I want to have executed when the prompt is
put on screen, but that would seem a rather nasty hack.

Thanks in advance for any help!

Kind regards,

Michael Scarpa

More information about the IPython-user mailing list