Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12835
| Date | 2011-09-06 16:18 +0200 |
|---|---|
| From | Laszlo Nagy <gandalf@shopzeus.com> |
| Subject | Re: Python marks an instance of my class undefined |
| References | <CAPbrmCumW-mcJvsER-GQUDQUeuqmtvsH9kD2usZVWaW4pgb=hQ@mail.gmail.com> <CAPbrmCu0PEQgZg0DMej073p+zzfc266uZAiWQ3pt-WZiHoFafQ@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.802.1315318727.27778.python-list@python.org> (permalink) |
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()
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Python marks an instance of my class undefined Laszlo Nagy <gandalf@shopzeus.com> - 2011-09-06 16:18 +0200 Re: Python marks an instance of my class undefined Hans Mulder <hansmu@xs4all.nl> - 2011-09-06 17:12 +0200
csiph-web