Odd behavior with imp.reload and logging

Chris Angelico rosuav at gmail.com
Thu Sep 22 04:12:49 EDT 2011


On Thu, Sep 22, 2011 at 5:59 PM, Andrew Berg <bahamutzero8825 at gmail.com> wrote:
> That's quite unappealing for a few reasons. First, that would likely
> require writing an entirely new bot (I'm not even that familiar with the
> current one; I've only been writing a module for it).

Ah, then yeah, it's probably not a good idea to change languages. But
you may end up finding other issues with reload() as well.

I wonder whether this would work...

modules=[]

# instead of 'import mymodule' use:
modules.append(__import__('mymodule')); mymodule=modules[-1]

In theory, this should mean that you load it fresh every time - I
think. If not, manually deleting entries from sys.modules might help,
either with or without the list of modules.

ChrisA



More information about the Python-list mailing list