On 6/09/11 16:18:32, Laszlo Nagy wrote:
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
name.

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()

An import statement always imports a module, but Python also has the
from...import statement to import one item from a module:

from core.fleet import Fleet
f = Fleet()

The convention is to use the name "Fleet" (with an initial capital)
for the class and "fleet" (all lower case) for the module.  This
makes it easier to not confuse the class and the module.

Hope this helps,

-- HansM





--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to