Can't import modules

Hans Mulder hansmu at xs4all.nl
Sun Sep 30 16:21:51 EDT 2012


On 30/09/12 21:42:37, Peter Farrell wrote:
> I'm still new to Python, so here's another easy one. After I save something
> I've done as a .py file, how do I import it into something else I work on?
> Every time I try to import something other than turtle or math, I get this error message:
> 
> 'module' object is not callable
> 
> What am I doing wrong?

For starters, you're not showing us any code.

The error message suggests that you have successfully imported
a module, and you then try to use the module as if it were a
callable.  That won't work: modules are not callable.

My crystal ball says that you may have been a Java programmer
in an earlier life.  In Java, a file must define exactly one
class, and the class must have the same name as the file.

Python is not Java.  In Python, a file may define one class,
or twenty, or none at all.  To avoid confusion, do not give
any of your classes the same name as any of your files.


Hope this helps,

-- HansM





More information about the Python-list mailing list