[Tutor] Module imports

Noufal Ibrahim noufal at airtelbroadband.in
Wed Jul 11 17:31:16 CEST 2007


kevin parks wrote:
> With sincere apologies for such a basic question, and one i will  
> admit that i asked once before, moons ago. But even after googling  
> around a bit i don't understand what the right answer is, or if i  
> once did, can't recall it now..

[..]
> 
> For some reason i feel like i should understand how and why this  
> works a little better in order to avoid overlap and conflict in what  
> is becoming a bit more involved intermingling of modules and scripts.

I don't think you need to worry. The python primitive "id" returns a 
unique identifier for it's argument (I recall reading the it's the 
memory location of the object).

Anyway, I have a module called foo.py which has this

import sys
print id(sys)


Then I start python and do this
import sys
print id(sys)
3084566644
import foo
3084566644
id(foo.sys)
3084566644
sys is foo.sys
True


So, it is the same object. You don't have to worry.

Peace.

-- 
~noufal


More information about the Tutor mailing list