import & __import__

Chris Armstrong punck at SpamIsBadPenguinPowered.com
Sun Mar 12 17:35:15 EST 2000


Bah. My bad. foobar = __import__("modulename") _does_ print out "Hi." I
thought I had checked that. :P
What _doesn't_ print out "Hi." is foobar.append(__import__("modulename")).
*shrug*

In article <2MUy4.5284$bt3.17551 at newsfeed.slurp.net>, Chris Armstrong <punck at SpamIsBadPenguinPowered.com> wrote:
> Hi all. I'm pretty much a newbie to Python, and I have a question about 
> import vs __import__. I'm implementing dynamically imported modules in
> a game I'm writing, and I need to use __import__ to do this. One thing I
> noticed is that __import__ doesn't seem to execute the modules that it
> imports, while import does.. The docs for __import__ don't mention anything
> about this, and I'm just curious about it. I tested this by making a simple
> module that just has `` print "Hi." '' in it. `` import modulename '' caused
> it to print out "Hi." while `` foobar = __import__("modulename") '' didn't.
> This isn't really important to me, I was just curious about it.

-- 
Chris Armstrong
http://drol.sourceforge.net

Geek code version 3.12
GCS d? s:-- a--- C+++ UL++++>++++ P++ L+++ E--- W++ N+ o? K- w-- 
O-- !M V PS+(+++) PE? Y+(--) PGP(--) t+ 5 X+ R tv+ b+>++ DI+ D+++ 
G e- h!(--) r- y?
Go to www.geekcode.com to find out what on earth this is.




More information about the Python-list mailing list