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

Discussion in 'Python' started by Xiao Jianfeng, Dec 16, 2005.

  1. 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
    Xiao Jianfeng, Dec 16, 2005
    #1
    1. Advertising

  2. 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 <>
    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
    --
    > ============================================================== <
    > | Wulfraed Dennis Lee Bieber KD6MOG <
    > | Bestiaria Support Staff <
    > ============================================================== <
    > Home Page: <http://www.dm.net/~wulfraed/> <
    > Overflow Page: <http://wlfraed.home.netcom.com/> <
    Dennis Lee Bieber, Dec 16, 2005
    #2
    1. Advertising

  3. Xiao Jianfeng

    Ben Finney Guest

    Re: The difference between "import package.module" and "frompackage import module"(about pymol)

    Xiao Jianfeng <> 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
    Ben Finney, Dec 16, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jakk
    Replies:
    4
    Views:
    12,139
  2. Santa
    Replies:
    1
    Views:
    1,074
    Mark A. Odell
    Jul 17, 2003
  3. Jeremiah

    python parser overridden by pymol

    Jeremiah, Nov 12, 2009, in forum: Python
    Replies:
    6
    Views:
    844
    Dave Angel
    Nov 13, 2009
  4. PerlFAQ Server
    Replies:
    0
    Views:
    355
    PerlFAQ Server
    Jan 6, 2011
  5. PerlFAQ Server
    Replies:
    0
    Views:
    260
    PerlFAQ Server
    Apr 15, 2011
Loading...

Share This Page