Python marks an instance of my class undefined

Laszlo Nagy gandalf at
Tue Sep 6 16:18:32 CEST 2011

On 2011-09-06 15:42, Kayode Odeyemi wrote:
> I was able to get this solved by calling class like this:
> >>> from core.fleet import Fleet
> >>> f = Fleet()
> Thanks to a thread from the list titled "TypeError: 'module' object is 
> not callable"
Or you can also do this:

import core.fleet # import module core.fleet under the name core.fleet
f = core.fleet.Fleet()

Please note that the import statement imports the module with the given 

So for example

import x.y.z

will import the name "x.y.z". Anything that is in module "z" will be 
available through its module, that is "x.y.z".
Whenever you use "import <name>", you have to access module contents 
through "<name>".

You can change the name:

import core.fleet as c # import module core.fleet under the name c
f = c.Fleet()

More information about the Python-list mailing list