Odd behavior with imp.reload and logging

Chris Angelico rosuav at gmail.com
Thu Sep 22 01:09:49 EDT 2011

On Thu, Sep 22, 2011 at 2:47 PM, Andrew Berg <bahamutzero8825 at gmail.com> wrote:
> This makes me wonder what else stays around after a reload and what side
> effects there are, though. I would really like to purge everything from
> the previous import. The main program has no dependence on the module
> whatsoever.

On-the-fly reloading of modules isn't really one of Python's
strengths. Everyone who asks about it seems to be doing rapid
development/debugging and wanting to save on startup time (as opposed
to, say, running a server and updating code in it while it's active
and serving clients), so the question becomes: Which is more of a
problem, startup delay or the risk that it's not the same as a clean
start? Python doesn't guarantee that your debugging session is going
to be useful - if you reload that module and weird things happen, it
could be because of reload(), not because of a module bug.

Ranting Rick will probably expect me to mention Pike here, but I
won't. Muahahahaha..... oh. I just did. Oh well!


More information about the Python-list mailing list