[IPython-dev] Package-specific extensions: an idea

Robert Kern robert.kern at gmail.com
Thu Jun 16 17:16:08 EDT 2011


On 6/16/11 3:18 PM, Fernando Perez wrote:
> On Tue, May 17, 2011 at 3:48 PM, Robert Kern<robert.kern at gmail.com>  wrote:
>> There's a general problem for writing package-specific extensions to IPython.
>> Namely, you want to be able to write and enable an extension to IPython that
>> provides special behavior for particular objects, say numpy arrays, without
>> requiring that a particular package be imported at startup. You can often get by
>> in ad hoc ways. For example, in the pretty-printing code, I added the ability to
>> register deferred type-checking. For magic functions, you can usually just do
>> local imports inside the magics.
>>
>> However, I've had an idea for a general solution.
>
> I'm kind of -1 on this approach right now, mostly because I really
> don't want to add more special paths to our execution logic.  Instead,
> we have already the ability for users to register any function they
> desire to execute afterwards:
>
> https://github.com/ipython/ipython/blob/master/IPython/core/interactiveshell.py#L689
>
> So my suggestion would be for this to be done by the user as a
> post-execute function.  We can certainly provide it pre-canned to
> eliminate the need for users to rewrite boilerplate, but I'd rather
> keep the main run* methods as tight as they can reasonably be in the
> main codebase.

What would the user experience look like in this scenario?

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the IPython-dev mailing list