modules and namespaces

Mage mage at mage.hu
Tue Apr 19 09:07:08 EDT 2005


       Hello,

I thought that this will work:

#m1.py
def f1():
    return string.join('a','a')

#m2.py
def f2():
    return string.join('b','b')

#main.py
import string
import m1
import m2

print f1()
print f2()

---------

However it doesn't work until I import the string module into m1 and m2
modules. I found in the manual that imported modules will be searched in
the container module first. Is it more efficient to import the string
module into main and m1 and m2 than importing only into m1 and m2?

       Mage





More information about the Python-list mailing list