By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,957 Members | 1,936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,957 IT Pros & Developers. It's quick & easy.

How to import a module that must override a standard one

P: n/a
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 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.

Mar 11 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.