Unfortunately, you've run across one of the weakness of python -
dynamic reloading/resourcing.
There are some workarounds - for instance, with the problem you're
having, I'm assuming what's going on is you're doing something like
this:
>>> from myModule import myFunc
*** make some changes to myModule.myFunc
>>> reload(myModule)
...at which point, if you try to use myFunc, it hasn't been updated -
the problem is the reference in the global namespace still points to
the OLD version of the module, so you may be able to fix this by
re-doing
>>> from myModule import myFunc
Unfortunately, this quickly gets pretty unmanagable if there is any
sort of complexity to your dependency tree, since you'd have to go
through and reload all the dependencies in reverse order, etc.
I know I read once of somebody who implemented an
"automatic-rewinding" reloader, that worked by overloading the import
and keeping track of dependencies, but I never tried it myself, so I
have no idea how well it worked. (I was scared it would just be a
source of too many potential headaches / weird bugs). If you do try
it, lemme know.
But the short answer is... yeah, if you have any real complexity in
either your dependencies, or in your import namespacing, it's
generally easiest to restart.
- Paul