Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Unresolved relative import with wildcard

Anonymous
2011-05-30
2013-03-15

  • Anonymous
    2011-05-30

    Hello,
    I'm getting an unresolved import in the following scenario: I have a package 'mypackage' with two modules 'mymod1' and 'mymod2', the contents of which are as follows.

    mymod1.py:

    myattr = 42
    

    mymod2.py:

    from .mymod1 import *
    

    The error states:
    "Unresolved import: mymod1"

    However, if I remove the dot in my import statement, the import is resolved successfully. Obviously this can cause ambiguity, if I were to have a module named 'mymod1' in the root package.

    I've searched the forum, if a duplicate topic exists I apologize in advance.

    Thanks,
    Amnon

     

  • Anonymous
    2011-05-30

    I forgot to mention my configuration:
    * Eclipse 3.6.1
    * PyDev 2.0.0.20110404
    * Python 2.7 grammar, 2.7.1 interpreter

     
  • Fabio Zadrozny
    Fabio Zadrozny
    2011-05-30

    It's really a bug (please report it in the bug tracker - I'll take a look at why the relative import is having issues with wildcard imports).

    Cheers,

    Fabio

     

  • Anonymous
    2011-06-27

    Hey again Fabio,
    Thanks for addressing this issue. I've just updated to 2.2.0, and a notion of this issue yet remains unresolved.

    As a continuation to the example in my first message, suppose you have a deeper package "mypackage.deeper", and within it a python module "mymod3", the following code still causes an error ("Undefined variable: myattr"):

    from ..mymod1 import *
    print([u]myattr[/u])
    

    Thanks again,
    Amnon