Python marks an instance of my class undefined
Kayode Odeyemi
dreyemi at gmail.com
Tue Sep 6 10:32:19 EDT 2011
More information about the Python-list mailing list
Tue Sep 6 10:32:19 EDT 2011
- Previous message (by thread): Python marks an instance of my class undefined
- Next message (by thread): Python marks an instance of my class undefined
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Sep 6, 2011 at 3:18 PM, Laszlo Nagy <gandalf at shopzeus.com> 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() > > That is, import [package-name] .[class-name] If using from, that can take the form of [package-name].[pymodule] import [pymodule] or [class-name] I just got to understand it. Thanks. This explanation really simplifies it further. Can I do: from [pymodule] import [class-name], assuming the pymodule as a class instance? -- Odeyemi 'Kayode O. http://www.sinati.com. t: @charyorde -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-list/attachments/20110906/ff66ce1f/attachment-0001.html>
- Previous message (by thread): Python marks an instance of my class undefined
- Next message (by thread): Python marks an instance of my class undefined
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list