Altering imported modules

Bruno Desthuilliers bruno.42.desthuilliers at
Wed Mar 5 13:31:01 CET 2008

Tro a écrit :
> Hi, list.
> I've got a simple asyncore-based server. However, I've modified the asyncore 
> module to allow me to watch functions as well as sockets. The modified 
> asyncore module is in a specific location in my project and is imported as 
> usual from my classes.
> Now I'd like to use the tlslite library, which includes an asyncore mixin 
> class. However, tlslite imports "asyncore", which doesn't include my own 
> modifications.
> I'd like to know if it's possible to make tlslite load *my* asyncore module 
> without changing any of the tlslite code.

Not sure this apply to your case (depends on how asyncore is implemented 
and the exact "modifications"), but monkeypatching is a possible solution.


More information about the Python-list mailing list