[IPython-user] prompt problems

Fernando Perez Fernando.Perez at colorado.edu
Thu Mar 17 15:53:11 CST 2005

Bengt Frost wrote:
> Hi,
> I (still) have problem as follows:
> Python 2.3.4 (#1, Feb  7 2005, 20:36:44)
> Type "copyright", "credits" or "license" for more information.
> IPython 0.6.12 -- 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.
> bfrost[~] In[1] >>> for x in range(10):
>             <ERROR: PromptOut instance has no attribute 'col_p2'>
> My ~/.ipython/ipythonrc(with extra space):Python 2.3.4 (#1, Feb  7 2005,
> 20:36:44)
> # Added:
> prompt_in1 '\C_LightRed\u\C_LightBlue[\C_LightBlue\Y1\C_LightBlue]
> In[\C_LightGreen\#\C_LightBlue] \C_LightBlue>>> '
> # \D is replaced by as many dots as there are digits in the
> # current value of \#.
> prompt_in2 ' .\D.: '
> prompt_out 'Out[\#]: '
> Any ideas? Thanks!

Mmh, do you mean within emacs?  I'm not sure if the ipython.el is 
sophisticated enough to recognize these more customized prompts.  Here's the 
relevant section of ipython.el:

(defvar ipython-de-input-prompt-regexp "\\(?:
In \\[[0-9]+\\]: .*
----+> \\(.*
In \\[[0-9]+\\]: \\(.*
\\)\\)\\|^[ ]\\{3\\}[.]\\{3,\\}: \\(.*
   "A regular expression to match the IPython input prompt and the python
command after it. The first match group is for a command that is rewritten,
the second for a 'normal' command, and the third for a multiline command.")

The problem is that ipython prompts can be arbitrarily dynamic (as I recently 
showed in the -dev list).  You can pretty much evaluate anything you want in 
there, including runtime-dependent code.  So it's probably impossible for 
emacs to catch all cases.

Can you test with the simpler prompts I sent?  If those work for you, it may 
be the case that, _for emacs use_, you need to restrict yourself to slightly 
less fancy prompts.  You can always set your emacs config to load ipython with 
a special profile, where you define an emacs-friendly prompt, even if at a 
terminal you want to use more complex ones.  Here's how I have mine set:

(setq py-python-command-args '("-pylab" "-p" "pylab" "-colors" "LightBG"))

Or perhaps our resident emacs gurus can come up with a better solution, which 
I'd gladly include in the docs (or modify the distributed ipython.el if 



More information about the IPython-user mailing list