problem of double import in python
Joel Goldstick
joel.goldstick at gmail.com
Mon Sep 2 21:29:45 EDT 2013
On Mon, Sep 2, 2013 at 9:16 PM, Mohsen Pahlevanzadeh
<mohsen at pahlevanzadeh.org> wrote:
> When i uncomment
> ////
> from common.interface.interface import ShowHide
The line above only loads interface.interface.ShowHide
I
> ////
> in file contains Ui_Materials class i get the following traceback:
> //////////////////////////
> Traceback (most recent call last):
> File "./main.py", line 110, in <module>
> main()
> File "./main.py", line 91, in main
> interfaceObj.showMaterials()
> File
> "/home/mohsen/codes/amlak/amlak/src/common/interface/interface.py", line
> 80, in showMaterials
> self.ui = Ui_Materials()
> NameError: global name 'Ui_Materials' is not defined
You should do this:
import common.interface.interface
later do this:
self.ui = common.interface.interface.Ui_Materials()
If you are annoyed by the long names you can do this:
import common.interface.interface as ci
then
self.ui = ci.Ui_Materials.
Look up the section in python.org on importing modules to learn more
--
Joel Goldstick
http://joelgoldstick.com
More information about the Python-list
mailing list