Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
__import__ returns module without it's attributes?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dave Angel  
View profile  
 More options Nov 14, 11:05 am
Newsgroups: comp.lang.python
From: Dave Angel <da...@ieee.org>
Date: Sat, 14 Nov 2009 11:05:44 -0500
Local: Sat, Nov 14 2009 11:05 am
Subject: Re: __import__ returns module without it's attributes?

I'm probably not the one to give you the actual answer (at least not in
the next couple of days), but I could help you ask a better question.

Provide a simple example of your code, and what it does.  Describe the
python version and OS platform you're running it on.  And detail the
contents of any extra files or environment values that are needed to
reproduce the problem.

(You may find http://www.catb.org/~esr/faqs/smart-questions.html  useful)

BTW, I don't know of any method __import__(), only a builtin function,
so I don't see how you can overload it. But your example should make it
clear what you really meant.

HTH
DaveA


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gabriel Genellina  
View profile  
 More options Nov 15, 11:32 am
Newsgroups: comp.lang.python
From: "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
Date: Sun, 15 Nov 2009 13:32:01 -0300
Local: Sun, Nov 15 2009 11:32 am
Subject: Re: __import__ returns module without it's attributes?
En Fri, 13 Nov 2009 20:27:29 -0300, Zac Burns <zac...@gmail.com> escribió:

> I've overloaded __import__ to modify modules after they are
> imported... but running dir(module) on the result only returns
> __builtins__, __doc__, __file__,
> __name__, __package__, and __path__.

> Why is this? More importantly, where can I hook in that would allow me
> to see the contents of the module?

Post some code. This works for me:

py> import __builtin__
py> builtin_import = __builtin__.__import__
py> def __import__(*args):
...   module = builtin_import(*args)
...   module.__signature__ = "kilroywashere"
...   return module
...
py> __builtin__.__import__ = __import__
py>
py> import htmllib
py> dir(htmllib)
['AS_IS', 'HTMLParseError', 'HTMLParser', '__all__', '__builtins__',
  '__doc__', '__file__', '__name__', '__package__', '__signature__',
  'sgmllib', 'test']
py> htmllib.__signature__
'kilroywashere'

--
Gabriel Genellina


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google