[IPython-user] import local_module requires reload(local_module)

Fernando Perez fperez.net@gmail....
Thu Jan 31 01:48:35 CST 2008

On Jan 24, 2008 8:34 AM, Alan Brogan <ipython@al-got-rhythm.net> wrote:
> Hello the list,
> I have tried list archives and general Googling, but still cannot figure out
> how to crack this one. Hopefully someone on the list can point me towards a
> FAQ.
> The question is about "import path", that wonder module from Jason
> Orendorff. I have modified it to pass all the commands through a logger, and
> generally need to import that version of the module. In Python this proceeds
> smoothly when I run from the dir containing my version of path.py, see
> transcript below. But in ipython I need to import, then reload the path
> module. (Again, see transcript below). This reload is also needed when
> importing other modules from this directory, so that instead of a simple
> "import other" I need to do a "import path; reload(path); import other"
> dance.
> How do I get over this glitch ?

The issue is that IPython ships with Jason's path module in
Extensions, and by default it injects Extensions into sys.path.  I'm
not sure this is a good idea, IPython should really leave sys.path
alone, and let users either modify $PYTHONPATH or manually tweak
sys.path in their startup scripts if they so desire.

Unconditionally modifying sys.path is likely to cause problems of this
nature.  Ville, I think you introduced that for Extensions, any
particular reason why? I'm thinking this should probably be fixed...



More information about the IPython-user mailing list