hidden built-in module

Michael Wieher michael.wieher at gmail.com
Fri Mar 7 15:23:28 CET 2008


2008/3/7, koara <koara at atlas.cz>:
>
> On Mar 5, 1:39 pm, gigs <g... at hi.t-com.hr> wrote:
> > koara wrote:
> > > Hello, is there a way to access a module that is hidden because
> > > another module (of the same name) is found first?
> >
> > > More specifically, i have my own logging.py module, and inside this
> > > module, depending on how initialization goes,  i may want to do 'from
> > > logging import *' from the built-in logging.
> >
> > > I hope my description was clear, cheers.
> >
> > > I am using python2.4.
> >
> > you can add your own logging module in extra directory that have
> __init__.py and
> > import it like: from extradirectory.logging import *
> >
> > and builtin: from logging import *
>
>
> Thank you for your reply gigs. However, the point of this namespace
> harakiri is that existing code which uses 'import logging' ...
> 'logging.info()'... etc. continues working without any change.
> Renaming my logging.py file is not an option -- if it were, i wouldn't
> bother naming my module same as a built-in :-)
>
> Cheers.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

I've never had a problem like this, but I'd imagine that you could delve
into the inner-workings of import itself and figure a way to make this
happen.  There's probably a logical-order search path it follows, and if you
can find a way to insert your module before the other, in that path, or
modify the path and point its first entry at say, a directory containing
only your module, you'd be in business.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080307/54347203/attachment.html>


More information about the Python-list mailing list