[Tutor] Reload() in v3? WAS Re: IDEs
Steven D'Aprano
steve at pearwood.info
Sat Nov 27 22:52:37 CET 2010
Alan Gauld wrote:
>>>> import os
>>>> reload(os)
> Traceback (most recent call last):
> File "<pyshell#65>", line 1, in <module>
> reload(os)
> NameError: name 'reload' is not defined
>>>>
>
> Has reload been removed in V3?
Not removed, just moved.
>>> import imp
>>> imp.reload
<built-in function reload>
The reason for moving it is that reload is quite simple-minded and full
of traps for the unwary, and consequently isn't useful enough to be in
the build-it namespace.
> Whats the alternative? Does a repeated import auto-reload?
Absolutely not! That would make importing much more expensive, and
change the behaviour. import(module) caches the module in sys, so that
subsequent imports are fast.
--
Steven
More information about the Tutor
mailing list