Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > hidden built-in module

Reply
Thread Tools

hidden built-in module

 
 
gigs
Guest
Posts: n/a
 
      03-05-2008
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 *
 
Reply With Quote
 
 
 
 
koara
Guest
Posts: n/a
 
      03-07-2008
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.
 
Reply With Quote
 
 
 
 
koara
Guest
Posts: n/a
 
      03-07-2008
On Mar 5, 1:39 pm, gigs <(E-Mail Removed)-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.
 
Reply With Quote
 
Diez B. Roggisch
Guest
Posts: n/a
 
      03-07-2008
koara schrieb:
> On Mar 5, 1:39 pm, gigs <(E-Mail Removed)-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


You can only try and search the sys-path for the logging-module, using

sys.prefix

and then look for logging.py. Using

__import__(path)

you get a reference to that module.

Diez
 
Reply With Quote
 
Gabriel Genellina
Guest
Posts: n/a
 
      03-07-2008
En Fri, 07 Mar 2008 12:15:04 -0200, koara <(E-Mail Removed)> escribi�:
> On Mar 5, 1:39 pm, gigs <(E-Mail Removed)-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.

>>
>> 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


Read a very recent post from Bruno Desthuilliers with subject "Altering
imported modules"

--
Gabriel Genellina

 
Reply With Quote
 
koara
Guest
Posts: n/a
 
      03-07-2008
> You can only try and search the sys-path for the logging-module, using
>
> sys.prefix
>
> and then look for logging.py. Using
>
> __import__(path)
>
> you get a reference to that module.
>
> Diez



Thank you Diez, that's the info i'd been looking for

So the answer is sys module + __import__

Cheers!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate Hidden field on post back and retrieve value from Hidden Field Rick ASP .Net 3 04-13-2010 05:38 PM
Win 7 folders hidden despite 'show hidden' checked Boppy NZ Computing 10 01-23-2010 02:56 AM
Re: module docstring, documentation,anything? please note is the module type/object NOT some module Maric Michaud Python 0 06-24-2006 12:42 PM
How would I discover the text in a block element hidden by overflow:hidden style being set? SolarCanine Javascript 2 09-20-2005 06:27 PM
Compile error in hidden module : NT Reg Code Pedro69UK Computer Support 0 01-12-2004 09:15 AM



Advertisments