Bug in handling of single underscore identifiers?

Discussion in 'Python' started by Tom Blackwell, Jan 4, 2005.

  1. Today I installed the 'mechanoid' package from sourceforge, but the
    self-test failed. On looking into it, I noticed odd behaviour in the
    handling of single underscore module names. Importing into the
    current namespace with 'from' seems to work, but accessing members of
    the imported module only works if the imported name is qualified by
    the containing module name.

    For example:
    >>> from mechanoid import _mechanoid_Common
    >>> from _mechanoid_Common import Common

    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    ImportError: No module named _mechanoid_Common
    >>> from mechanoid._mechanoid_Common import Common

    **succeeds**
    >>> _mechanoid_Common

    <module 'mechanoid._mechanoid_Common' from
    'mechanoid\_mechanoid_Common.pyc'>

    Is this a bug or a feature? The language reference section 2.3.2
    'Reserved classes of identifiers' indicates that identifiers starting
    with a single underscore are not imported by "from module import *".
    However I can't find any indication that "from module import _name"
    should work this way.

    Thanks

    Tom
    Tom Blackwell, Jan 4, 2005
    #1
    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. Antonio
    Replies:
    2
    Views:
    417
    tdavisjr
    Nov 4, 2005
  2. Kerry Kimbrough
    Replies:
    6
    Views:
    14,724
    Chris Smith
    Feb 27, 2004
  3. Chris Green
    Replies:
    2
    Views:
    330
    Michael Schutte
    Dec 18, 2003
  4. Steven W. Orr

    Question about a single underscore.

    Steven W. Orr, Feb 1, 2007, in forum: Python
    Replies:
    10
    Views:
    527
    Bruno Desthuilliers
    Feb 1, 2007
  5. Replies:
    1
    Views:
    333
    Roedy Green
    Apr 22, 2008
Loading...

Share This Page