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


Groups > comp.lang.python > #53549

Re: problem of double import in python

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <joel.goldstick@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.018
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'importing': 0.05; 'skip:" 60': 0.07; 'main()': 0.09; 'cc:addr:python-list': 0.11; 'nameerror:': 0.16; 'subject:import': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'later': 0.20; 'import': 0.22; 'cc:addr:python.org': 0.22; 'subject:problem': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'defined': 0.27; 'header:In-Reply- To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; 'loads': 0.31; 'sep': 0.31; 'file': 0.32; 'class': 0.32; 'python.org': 0.32; '(most': 0.33; 'received:google.com': 0.35; 'should': 0.36; 'pm,': 0.38; 'recent': 0.39; 'skip:u 10': 0.60; 'name': 0.63; 'more': 0.64; 'joel': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=llJT5loMb2i9wThWr85tn6d7+QCS26qZtyIoVFHgZcY=; b=0Wgt/E1o820b1iwML6JWmD1Z5B9icO0nwpgJoCEduTBMOaOWmgSGHpbnmqABtqR3/T Dntj57pDaD/PWatWocxg2cBhYWxJxVmwRbIu/hts83/dAN0SO8N///WGSQC+Fmo9UjgU hxSejAEB9v8NXNhPdgxeXrs5QHm/q9vbiGfSLxTpkGXZRz1wJnEqTv2zQ1p40YY9Fb7W zADeFKO+xFUwyVGUeVyUYVZluo9Wno1gRhA/dTRGAKUtGomSUjJf2COkSSn8lBbpIcir Negd1nkI4jR4zPHYvYXqUJdBV754odbB76NfVuW/M5rEgmpR36eRSOiIQsgIBC9egaLp +xAQ==
MIME-Version 1.0
X-Received by 10.58.161.116 with SMTP id xr20mr22223390veb.2.1378171785412; Mon, 02 Sep 2013 18:29:45 -0700 (PDT)
In-Reply-To <1378170986.6921.19.camel@debian>
References <1378169284.6921.16.camel@debian> <1378170986.6921.19.camel@debian>
Date Mon, 2 Sep 2013 21:29:45 -0400
Subject Re: problem of double import in python
From Joel Goldstick <joel.goldstick@gmail.com>
To Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org>
Content-Type text/plain; charset=UTF-8
Cc "python-list@python.org" <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.530.1378171788.19984.python-list@python.org> (permalink)
Lines 43
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1378171788 news.xs4all.nl 15877 [2001:888:2000:d::a6]:41253
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:53549

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web