Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   The difference between "import package.module" and "from packageimport module"(about pymol) (http://www.velocityreviews.com/forums/t352566-the-difference-between-import-package-module-and-from-packageimport-module-about-pymol.html)

Xiao Jianfeng 12-16-2005 04:54 AM

The difference between "import package.module" and "from packageimport module"(about pymol)
 
Hello,

In pymol I can use "from chempy import Atom" but "import chempy.Atom"
doesn't work.
It says,"ImportError: No module named Atom". What is going wrong ?

Thanks

Dennis Lee Bieber 12-16-2005 05:53 AM

Re: The difference between "import package.module" and "from package import module"(about pymol)
 
On Fri, 16 Dec 2005 12:54:49 +0800, Xiao Jianfeng <fdu.xiaojf@gmail.com>
declaimed the following in comp.lang.python:

> Hello,
>
> In pymol I can use "from chempy import Atom" but "import chempy.Atom"
> doesn't work.
> It says,"ImportError: No module named Atom". What is going wrong ?
>

"from X import Y" says: read module (file) X, make a LOCAL binding
named Y to the Y object found inside module X.

"import X.Y" says: find the MODULE (file) Y located in the PACKAGE
(directory) X
--
> ================================================== ============ <
> wlfraed@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
> wulfraed@dm.net | Bestiaria Support Staff <
> ================================================== ============ <
> Home Page: <http://www.dm.net/~wulfraed/> <
> Overflow Page: <http://wlfraed.home.netcom.com/> <


Ben Finney 12-16-2005 08:20 AM

Re: The difference between "import package.module" and "frompackage import module"(about pymol)
 
Xiao Jianfeng <fdu.xiaojf@gmail.com> writes:
> In pymol I can use "from chempy import Atom" but "import chempy.Atom"
> doesn't work.
> It says,"ImportError: No module named Atom". What is going wrong ?


I would trust the error message first, and check your assumption.

Is 'chempy' actually a package, containing an 'Atom' module? Or is
'chempy' actually a module, containing an 'Atom' attribute?

--
\ "I washed a sock. Then I put it in the dryer. When I took it |
`\ out, it was gone." -- Steven Wright |
_o__) |
Ben Finney


All times are GMT. The time now is 10:11 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.