'reload M' doesn't update 'from M inport *'
Tim Roberts
timr at probo.com
Sat Jul 10 19:24:59 EDT 2010
Frederic Rentsch <anthra.norell at bluewin.ch> wrote:
>
>I develop in an IDLE window.
>
>Module M says 'from service import *'.
>Next I correct a mistake in function 'service.f'.
>Now 'service.f' works fine.
>
>I do 'reload (service); reload (M)'.
>The function 'M.f' still misbehaves.
>
>'print inspect.getsource (service.f)' and
>'print inspect.getsource (M.f)' shows the same
>corrected code.
>
>'print service.f' and 'print M.f' show different ids.
Yes. This:
from service import xxx
is essentially the same as:
import service
xxx = service.xxx
At that point, xxx contains a reference to the "service.xxx" object as it
is right now. When you do a reload, that imports a new version of
"service.xxx", but your global "xxx" object is still bound to the old one.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list