[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: Altering imported modules

Tro

3/5/2008 6:16:00 AM

On Tuesday 04 March 2008, Steve Holden wrote:
> >> Are you trying to interfere with the default module on only your
> >> machine? Just rename it. If something in the std. lib. imports
> >> asyncore, they get yours too that way.
> >
> > No, I'd like it to be a generalized solution and only for this one
> > project. I'm trying to get it to work on any recent python installation
> > out of the box, so I can't rename built-in modules. What I'm trying to do
> > is allow a 3rd party module (tlslite) to import *my* version of asyncore
> > without me going into tlslite's code and changing its import statement
> > explicitly, but only for the scope of this one project.
>
> In that case try something like
>
> import myasyncore as asnycore
> sys.modules['asyncore'] = asyncore
> import tlslite

Ah. That's what I've been looking for. Thanks!

Tro