reload() gone?

Chris Mellon arkanes at gmail.com
Fri Aug 31 23:25:00 CEST 2007


On 8/31/07, Arnaud Delobelle <arnodel at googlemail.com> wrote:
> On Aug 31, 7:10 pm, "Bernard Lebel" <3dbern... at gmail.com> wrote:
> > I read in the Python 3.0 documentation that reload() was removed,
> > without further explanations.
> >
> > http://docs.python.org/dev/3.0/whatsnew/3.0.html?highlight=reload
> >
> > So what are we supposed to do to reload modules?
> >
> PEP 3100 says: use exec() instead.
>

However, it provides no information on how to do this. exec("import
foo") doesn't do it. exec(open(foo.__file__)) doesn't work either, but
that might just be teething problems (open returns a TextIOWrapper
object which exec doesn't identify as a file).

exec(open(foo.__file__).read(), foo.__dict__) was the best I could
come up with. That's frigging horrible, and it won't work unless
you've got access to the actual python source file of the module.



More information about the Python-list mailing list