[IPython-user] Prompt expressions

Walter Dörwald walter at livinglogic.de
Wed Jun 21 08:47:01 CDT 2006


Ville Vainio wrote:
> On 6/16/06, Michael Scarpa <m.scarpa at uva.nl> wrote:
> 
>> Looks nice, but since it's all moving to hooks anyway:  The reason why I
>> am using prompt expressions is that I have a function that I want to be
>> executed every time *after* the execution of the last input.  Since
>> IPython outputs the input-prompt after the execution, I simply tucked my
>> function call into the prompt.  Now, is there (or is there going to be)
>> a hook to do this in a more elegant way than re-implementing the
>> standard IPython input-prompt-hook with the added function call?  In the
>> end I don't need to change the prompt, but tho have my function be
>> called after the processing of the last user input.
> 
> Any ideas how it could be most useful? I figure we could have
> input_postfilter or something, but it would be too close to
> result_display hook (that already exists) for my taste...
> 
> Any other opinions?

A difference between the result_display hook and the input_postfilter
might be that for the result_display hook the first hook that handles
the object cancel further processing. For the input_postfilter handlers
further down the chain might want to process the object too.

And BTW input_postfilter sounds to me as it would be called between
inputting the code and executing it and not between executing it and
printing the result.

Servus,
   Walter




More information about the IPython-user mailing list