[IPython-user] Need post_runcode_hook
Mon Sep 29 13:14:46 CDT 2008
This is worth discussing further.
We should probably have hooks for pre, during and post execution. I
don't have much time right now, but some quick thoughts:
* The hook that gets run for the actual code execution, should get
passed the string of code that was entered (not the complied code).
The reason for this is that it opens the door for IPython to
understand other languages. For instance, you could have a %fortran
magic that uses the hook - then a user could simply type fortran code
in and we (someone?) could use the code along with f2py to
automatically wrap the fortran code. Sage uses this type of thing
* Currently, the %autopx magic hacks the runcode method to do
something like this. This magic could use these hooks. One thing
that it important though is that the hooks are designed in a way that
allows the default to be quickly reset.
On Sat, Sep 27, 2008 at 10:12 AM, Ville M. Vainio <email@example.com> wrote:
> On Sat, Sep 27, 2008 at 6:22 PM, Gustavo Carneiro <firstname.lastname@example.org> wrote:
>> Hello, I think I need a post_runcode_hook in interactive python module
> Frankly, I think that whenever there is a use case for a hook to the
> extent that someone considers monkeypatching, it should be added (to
> allow more stuff being moved away from the monolithic part of the
> core). So yes, I'll add it soon.
> While I'm at it, I could also add a run_code_hook that would enable
> customizing the 'exec code_obj in self.user_global_ns, self.user_ns'
> part (which would allow overriding one of the most critical phases of
> ipython code execution). It could even be used to implement the
> current MTInteractiveShell stuff in extension (w/o subclassing), which
> could be enabled "on the fly" by importing an extension.
> Ville M. Vainio
> IPython-user mailing list
More information about the IPython-user