[IPython-dev] autoload and making %pydb be more ipythonic (was: Extensions/pydb_ipy.py added)
Ville M. Vainio
vivainio at gmail.com
Fri Nov 24 11:27:57 EST 2006
On 11/24/06, R. Bernstein <rocky at panix.com> wrote:
> I don't have a problem adding ipy_pydb.py in the pydb package. But the one thing though that I think would somehow be nice is that if one *didn't* have to do run "import ipy_pydb" to allow %pydb to work. Given that one can put this in a "try" block, I don't see any downside of doing this.
It's just that having to import ipy_pydb would make enabling pydb a
configuration option. Sometimes one may wish to use standard pdb even
when pydb is installed.
And the import need not be manual - it's quite easy to add "import
ipy_pydb" to your personal ipy_user_conf.py.
> A cool and more general mechanism for ipython extensions would be something along the lines of Emacs Lisp "autoload". Say if I run %xxx ... then if that's not registered, try to run "import ipy_xxx" (where for example xxx = pydb), and then run %xxx .... Comments?
Well, this might save us some startup time & memory footprint. It
should be quite easy to do, esp. for magics (and completers). We can
easily inject stub callables in place of magics, which 1) import a
specified module and 2) try to run the magic again.
I think a good first line of action would be to add an ipapi function
that permanently registers a magic name / completer trigger (or
whatever) with ipython.
Here's what one could do e.g. in setup.py for pydb:
import IPython.ipapi
ip = IPython.ipapi.get()
ip.register_autoload("%pydb", "pydb.ipy_pydb")
--
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'
More information about the IPython-dev
mailing list