Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53549 > unrolled thread

Re: problem of double import in python

Started byJoel Goldstick <joel.goldstick@gmail.com>
First post2013-09-02 21:29 -0400
Last post2013-09-02 21:29 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: problem of double import in python Joel Goldstick <joel.goldstick@gmail.com> - 2013-09-02 21:29 -0400

#53549 — Re: problem of double import in python

FromJoel Goldstick <joel.goldstick@gmail.com>
Date2013-09-02 21:29 -0400
SubjectRe: problem of double import in python
Message-ID<mailman.530.1378171788.19984.python-list@python.org>
On Mon, Sep 2, 2013 at 9:16 PM, Mohsen Pahlevanzadeh
<mohsen@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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web