Menu

#1073 import * from module marked as unresolved.

open-rejected
Editor (491)
5
2010-03-09
2010-02-18
No

We have a module containing a number of different classes inside different files named after the class; for example class XEncoder is inside a file called XEncoder.py inside the module directory. To prevent insane imports we import all classes inside a module into the module level namespace inside __init__.py and then import * from the module.

e.g.:
Module directory structure:
./foo/bar/__init__.py
./foo/bar/MyClassA.py
./foo/bar/MyClassB.py

__init__.py:
from .MyClassA import *
from .MyClassB import *
... etc

Within MyClassA.py we do:
from .bar import * to import class definitions from the other files inside the module.

This works if you run the script - but PyDev editor marks any of the imported class names as undefined variables.

Similarly if you do MyClassA.MyStaticClassVariable inside MyClassB having done the import "MyStaticClassVariable" is marked as undefined, but runs fine in reality.

Pydev version 1.5.4.2010011921

Discussion

  • Peter Harris

    Peter Harris - 2010-02-18

    If you explicitly import

    "from .bar import MyClassA"

    Pydev works fine - so just looks like a name resolution error on relative imports containing "*".

     
  • Peter Harris

    Peter Harris - 2010-03-09

    Ah - .module is not a valid python import - my mistake.

     
  • Peter Harris

    Peter Harris - 2010-03-09
    • status: open --> open-rejected
     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.