[Tutor] import confusion
Marc Tompkins
marc.tompkins at gmail.com
Mon Jan 26 07:36:20 CET 2009
On Sun, Jan 25, 2009 at 9:45 PM, Eric Abrahamsen <eric at ericabrahamsen.net>wrote:
>
> Thanks for the break-down! I've got a fairly good handle on how to make all
> this work correctly, I guess what I'm after is an understand of why the
> above produces an error. What's going on in the system's module accounting
> that makes one thing work and the other fail?
>
Don't know about the internals, but here's a passage from the 2.61 docs (
http://docs.python.org/tutorial/modules.html):
> Note that when using from package import item, the item can be either a
> submodule (or subpackage) of the package, or some other name defined in the
> package, like a function, class or variable. The import statement first
> tests whether the item is defined in the package; if not, it assumes it is a
> module and attempts to load it. If it fails to find it, an ImportError<http://docs.python.org/library/exceptions.html#exceptions.ImportError>exception is raised.
>
> Contrarily, when using syntax like import item.subitem.subsubitem, each
> item except for the last must be a package; the last item can be a module or
> a package but can't be a class or function or variable defined in the
> previous item.
>
>
--
www.fsrtechnologies.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090125/29705fcd/attachment-0001.htm>
More information about the Tutor
mailing list