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


Groups > comp.lang.python > #68570

Re: [Python-Dev] Issues about relative& absolute import way for Portingfrom python2.4 to python2.7

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.04; 'subject:Python': 0.06; 'failing': 0.07; 'idea?': 0.09; 'imported': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'wrote': 0.14; '__init__.py': 0.16; 'foo.': 0.16; 'imports': 0.16; 'porting': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:Dev': 0.16; 'subject:import': 0.16; 'subject:python2.7': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'module': 0.19; 'subject:] ': 0.20; 'import': 0.22; 'header:User-Agent:1': 0.23; 'this:': 0.26; 'header:X -Complaints-To:1': 0.27; 'problem': 0.35; 'there': 0.35; 'changing': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'how': 0.40; 'details': 0.65; 'sample': 0.67; 'believe': 0.68; 'export': 0.74; 'investigated': 0.84; 'subject:& ': 0.84; 'package:': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: [Python-Dev] Issues about relative& absolute import way for Portingfrom python2.4 to python2.7
Date Thu, 20 Mar 2014 08:21:03 +0100
Organization None
References <tencent_2BE3693E682BB54F2047A4BE@qq.com>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Gmane-NNTP-Posting-Host p57bdb635.dip0.t-ipconnect.de
User-Agent KNode/4.11.5
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.8291.1395300082.18130.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1395300082 news.xs4all.nl 2877 [2001:888:2000:d::a6]:52720
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:68570

Show key headers only | View raw


北冰洋 wrote:

> I just wrote a sample like this:
> testPy/
>          __init__.py
>          client.py
>          SoamFactory.c
>          SoamFactory.so
>          soamapi.py
>          sample/testP.py
> export PYTHONPATH=$(TEST_LOCATION):$(TEST_LOCATION)/testPy

> I found that soamapi was imported twice, and I investigated this is

> I don't know how to fix it. Is there any official way about how to porting
> this scenario or better idea?

Without looking into the details -- I believe that your problem stems from 
having a path into the package:

> export PYTHONPATH=$(TEST_LOCATION):$(TEST_LOCATION)/testPy

The above means that a module testPy.foo can also successfully be imported 
as foo. Try changing the path to

export PYTHONPATH=$(TEST_LOCATION)

If you get failing imports change every failing import

import foo

to

from testPy import foo

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


Thread

Re: [Python-Dev] Issues about relative& absolute import way for Portingfrom python2.4 to python2.7 Peter Otten <__peter__@web.de> - 2014-03-20 08:21 +0100

csiph-web