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

X

Xiao Jianfeng

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
 
D

Dennis Lee Bieber

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
--
 
B

Ben Finney

Xiao Jianfeng said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top