How do you develop in Python?

Chris Barker chrishbarker at home.net
Thu Jun 7 15:01:57 EDT 2001


Michael Hudson wrote:

> 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.

This is exactly the same problem as you can get using PythonWin, and why
I desperately wish there was a way for the IDE to NOT share the same
interpreter as the code you are writing. Then you could just re-start
the second interpreter.

Anyway, my solution is to use:

import B
reload(B)
# and then, of required:
from B import *

everywhere

when I'm pretty confident that B is finished (maybe not untill I'm
giving the code to someone else) I get rid of all the reloads. It's a
little slower, but it makes sure I'm always using an up to date version
of all my modules that are under develoment.

Just van Rossum wrote:

> It's simple: if you modify B.py, _run_ B.py to refresh it (*). A.py will see
> the changes. It's hardly ever neccesary to quit the MacPython IDE.
> 
> *) In other words: if B.py has already been imported, running it it will
> execute it in B's old namespace, effectively refreshing it for everybody
> to see.

This is a classic, why didn't I think of that? solution. I think I will
still use my method for stuff I'm changing a lot, it is less likely that
I will forget to do the refresh.

-Chris


-- 
Christopher Barker,
Ph.D.                                                           
ChrisHBarker at home.net                 ---           ---           ---
http://members.home.net/barkerlohmann ---@@       -----@@       -----@@
                                   ------@@@     ------@@@     ------@@@
Oil Spill Modeling                ------   @    ------   @   ------   @
Water Resources Engineering       -------      ---------     --------    
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------



More information about the Python-list mailing list