reload imported module

Michael Hudson mwh21 at cam.ac.uk
Wed Apr 5 18:18:46 CEST 2000


"Emile van Sebille" <emile at fenx.com> writes:

> I'm testing a new class in its own module from within
> idle.  Is there a way to reload y after having done:
> 
>     from x import y

reload(sys.modules['x']); from x import y

I don't think there's any feasible way to automate this.
 
> or is it easiest to just import x and reload it?

Yes.  This works too:

import module_with_really_long_name

mwrln = module_with_really_long_name

... use mwrln ...

reload(mwrln)

... use updated version ...

Cheers,
M.

-- 
  well, take it from an old hand: the only reason it would be easier
  to program in C is that you can't easily express complex  problems
  in C, so you don't.                   -- Erik Naggum, comp.lang.lisp



More information about the Python-list mailing list