[IPython-user] Prompt expressions
Ville Vainio
vivainio at gmail.com
Thu Jun 15 14:13:04 CDT 2006
On 6/15/06, Ville Vainio <vivainio at gmail.com> wrote:
> On 6/14/06, Fernando Perez <fperez.net at gmail.com> wrote:
>
> > On 6/13/06, Michael Scarpa <m.scarpa at uva.nl> wrote:
> > > Dear IPython users,
> > >
> >
> > > 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.
> >
> > It's a bug, I just filed a ticket for it:
> >
> > http://projects.scipy.org/ipython/ipython/ticket/69
> >
> > In the meantime, a state bit hack will do, ugly as it may be.
>
> I will fix this, but I think I'll do it by exposing the prompt
> calculation as a hook to expose this functionality in a predictable
> and simple manner (and thus squat 2 flies at the same time).
Done in SVN (rev 1365), here's an example:
In [1]: pycat myprompt.py
import os
from IPython import ipapi
def prompt_hook(self, cont):
if cont: return 'cont..'
return os.getcwd() + " >"
ipapi.get().set_hook('generate_prompt',prompt_hook)
In [2]: import myprompt
/home/ville/ipython >1 + (
cont..2 +
cont..3)
Out[3]: 6
/home/ville/ipython >
--
Ville Vainio - vivainio.googlepages.com
vainio.blogspot.com - g[mail | talk]='vivainio'
More information about the IPython-user
mailing list