Project organization and import

Dave Baum Dave.Baum at motorola.com
Mon Mar 5 21:02:28 CET 2007


In article <1173119492.198000.252500 at v33g2000cwv.googlegroups.com>,
 "Martin Unsal" <martinunsal at gmail.com> wrote:

> That too... although I think that's unfortunate. If reload() were
> reliable, would you use it? Do you think it's inherently unreliable,
> that is, it couldn't be fixed without fundamentally breaking the
> Python language core?

I wrote a module that wraps __import__ and tracks the dependencies of 
imports.  It then allows you to unload any modules whose source have
changed.  That seemed to work out nicely for multi-module projects.

However, one problem I ran into was that dynamic libraries don't get
reloaded, so if you are doing hybrid C++/Python development then this
doesn't help - you still have to restart the whole python process to
pick up changes in your C++ code.

I also didn't do a ton of testing.  It worked for a few small projects
I was working on, but I stopped using it once I ran into the dynamic
library thing, and at this point I'm used to just restarting python
each time.  I'm sure there are some odd things that some python modules
could do that would interfere with the automatic reloading code I
wrote.

If you're interested in the code, drop me an email.

Dave



More information about the Python-list mailing list