How to import a module that must override a standard one

I

ilochab

I'm writing a python package that will contain a logging service for
twisted in python style.
I'm using some modules I downloaded from a twisted trunk, that are not
released with twisted but have the same names.
One of them is log.py that is usually imported from twisted modules like:

from twisted.python import log

But I need to import __my__ log, and I need that all the other modules
that will use my package would import __my__ log module too.
So I see 2 options to do so, but neither of them satisfies me:
1) I put __my__ log in my package tree and I import it from there, but in
this way any other module must do the same (and this is bad for previous
twisted application that want to use my package)
2) I oblige any potential user to patch the standard twisted installation
with my modules, but this is even worse.

I'm quite sure there is some pythonic way to override the original
twisted's log module after its first import with my one: I just don't
know how to do it.

So I'll patiently wait for an answer from this group.

Ciao!
Licia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,060
Latest member
BuyKetozenseACV

Latest Threads

Top