On 10/18/07, warhero <[EMAIL PROTECTED]> wrote: > Hey all, sorry for the totally newb question. I recently switched over > to python from ruby. I'm having problems figuring out how module > importing works.. as a simple example I've got these files: > > /example/loader.py > /example/loadee.py > > loadee.py > class loadee(object): > def __init__(self): > print "loadee" > > loader.py > import loadee > if __name__ == "__main__": > l = loadee() > > > When I run the loader file I get a TypeError: TypeError: 'module' > object is not callable
'import module' statement imports the 'module' object and binds the name to the local namespace. Any names defined in the module will have to referenced by module.module_object so you need to do something like this: import loadee if __name__ == "__main__": l = loadee.loadee() Alternatively you can directly import the objects defined in a module by : from loadee import loadee if __name__ == "__main__": l = loadee() cheers, -- -- Amit Khemka -- http://mail.python.org/mailman/listinfo/python-list