[IPython-user] autoreload 1 and aimport don't seem to work

Amir amirnntp@gmail....
Wed Sep 17 13:13:28 CDT 2008


khosra <amirnntp <at> gmail.com> writes:

> 
> 
> Pauli Virtanen-3 wrote:
> > 
> > It's a bug (my bad, sorry!), incorrect use of __import__ in the 
> > autoreload extension. Instead of 
> > 
> > 	mod = __import__(modname)
> >         ip.to_user_ns({modname: mod})
> > 
> > it should say
> > 
> > 	__import__(modname)
> > 	ip.to_user_ns({modname: sys.modules[modname]})
> > 
> > in ipy_autoreload.py
> > 
> > 
> > You should still be able to do
> > 
> > 	aimport reload_test.reload_me
> > 	import reload_test.reload_me
> > 
> > and then hopefully works.
> > 
> 
> I made the change in ipy_autoreload.py but I still get the NameError as
> before. aimport and then import work fine as you suggested. 
> 

In stock 9.1, autoreload still has the problem above. I modified
ipy_autoreload.py as Pauli instructed above but it doesn't work for modules in
subdirectories, i.e.

aimport module.module1

doesn't import module.module1 into namespace. And,

aimport module.module1
import module.module1

does not update after the file module.module1.py is modified.

Is there a modification of ipy_autoreload.py that would fix this?




More information about the IPython-user mailing list