How do you develop in Python?
Michael Hudson
mwh at python.net
Tue Jun 5 15:24:14 EDT 2001
Lou Pecora <pecora at anvil.nrl.navy.mil> writes:
> I program in Python occassionally and would like to do more of it. But
> here's a development conundrum I run into a lot (there are more complex
> examples, but I'll give an easy one). I am developing module A.py
> which imports B.py in the IDE. I am running test code which is also in
> A.py as I incrementally develop A.py. Then I need to change B.py and,
> of course, the import does not import the new changes since import only
> works once. Hence, to "refresh" B.py I have to quit the IDE and
> restart, open A.py and run. This is clumsy. However, the above
> scenario is not uncommon and more complex interdependencies of modules
> appear to make it unavoidable. Anyone know a way to get around this
> "import" problem? I know there is a "reload", but then I have to
> import and change my modules' code to "reload" or something each time I
> work with them. Any help appreciated.
If module A.py goes
import B
... uses B ...
and then in the top-level you type
>>> import A
>>> import B
then change B.py
then in the top-level typing
>>> reload(B)
modifies B in place, so code inside A should get the new version of
the module.
This doesn't work if you've used
from B import ...
in A; then you need to reload A too.
I don't see where you get the
> Hence, to "refresh" B.py I have to quit the IDE and restart, open
> A.py and run.
but I'd have to admit that I don't use the MacPython IDE, so I might
be missing some specific detail of that implementation. But I don't
think so.
Cheers,
M.
--
. <- the point your article -> .
|------------------------- a long way ------------------------|
-- Cristophe Rhodes, ucam.chat
More information about the Python-list
mailing list