<div class="gmail_quote">On Tue, Sep 6, 2011 at 3:18 PM, Laszlo Nagy <span dir="ltr"><<a href="mailto:gandalf@shopzeus.com">gandalf@shopzeus.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 2011-09-06 15:42, Kayode Odeyemi wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I was able to get this solved by calling class like this:<br>
<br>
>>> from core.fleet import Fleet<br>
>>> f = Fleet()<br>
<br>
Thanks to a thread from the list titled "TypeError: 'module' object is not callable"<br>
</blockquote></div>
Or you can also do this:<br>
<br>
import core.fleet # import module core.fleet under the name core.fleet<br>
f = core.fleet.Fleet()<br>
<br>
Please note that the import statement imports the module with the given name.<br>
<br>
So for example<br>
<br>
import x.y.z<br>
<br>
will import the name "x.y.z". Anything that is in module "z" will be available through its module, that is "x.y.z".<br>
Whenever you use "import <name>", you have to access module contents through "<name>".<br>
<br>
You can change the name:<br>
<br>
import core.fleet as c # import module core.fleet under the name c<br>
f = c.Fleet()<br>
<br></blockquote><div><br></div><div>That is, import [package-name] .[class-name]</div><div><br></div><div>If using from, that can take the form of [package-name].[pymodule] import [pymodule] or [class-name]</div><div><br>
</div><div>I just got to understand it.</div><div><br></div><div>Thanks. This explanation really simplifies it further.</div><div><br></div><div>Can I do:</div><div><br></div><div>from [pymodule] import [class-name], assuming the pymodule as a class instance?</div>
</div><br><br clear="all"><div><br></div>-- <br>Odeyemi 'Kayode O.<br><a href="http://www.sinati.com" target="_blank">http://www.sinati.com</a>. t: @charyorde<br><br>