Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'sys': 0.05; 'importerror:': 0.07; 'subject:changing': 0.07; 'namespace': 0.09; 'api': 0.09; '(where': 0.15; '153': 0.16; '4096': 0.16; 'behaviour,': 0.16; 'package).': 0.16; 'cc:addr:python-list': 0.16; '(most': 0.21; 'cc:no real name:2**0': 0.21; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'feb': 0.22; 'traceback': 0.24; 'module': 0.26; 'skip:[ 10': 0.27; 'import': 0.27; 'tried': 0.27; 'cc:addr:gmail.com': 0.28; 'example': 0.29; 'cc:addr:python.org': 0.29; 'message-id:@gmail.com': 0.31; 'header :User-Agent:1': 0.33; 'named': 0.33; 'file': 0.34; 'last):': 0.34; 'something': 0.35; 'received:209.85.214': 0.36; 'cc:2**1': 0.36; 'created': 0.37; 'received:10.0.0': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'some': 0.38; 'getting': 0.38; 'received:209': 0.39; 'missing': 0.40; 'total': 0.61; '14:36': 0.84; '14:46': 0.84; '14:47': 0.84; 'andrea': 0.84; 'python2': 0.84; 'order:': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=Ol/w84kTZNscYkyRk3Dt+KfQpxksyMv8qoBlRnSOy1U=; b=c7S/vsqVQNgPKQZDk96aIwEuYuRBoeqXSl0+6R1MWE5LuFnU7byG6LBkjahuIAJMDy EzB7J63pekVPsttmeQ1/kpVHxGRnJQXd3GWKaYJyVJPfr/gw9teI/rZ6+QVaUvoFoIvC 8Tce5tuT5QdE+u3yeoREuCK6oOh/yFVfNCx3A= Date: Fri, 10 Feb 2012 14:51:20 +0000 From: Andrea Crotti User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111224 Thunderbird/9.0.1 MIME-Version: 1.0 To: d@davea.name Subject: Re: changing sys.path References: <4F3516CC.1070401@gmail.com> <4F3528B2.3050806@davea.name> In-Reply-To: <4F3528B2.3050806@davea.name> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: python-list@python.org, Rick Johnson X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 73 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328885486 news.xs4all.nl 6982 [2001:888:2000:d::a6]:40251 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20165 Ok now it's getting really confusing, I tried a small example to see what is the real behaviour, so I created some package namespaces (where the __init__.py declare the namespace package). /home/andrea/test_ns: total used in directory 12 available 5655372 drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:46 a.b drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:46 a.c -rw-r--r-- 1 andrea andrea 125 Feb 10 14:46 test.py /home/andrea/test_ns/a.b: total 8 drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:47 a -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py /home/andrea/test_ns/a.b/a: total 8 drwxr-xr-x 2 andrea andrea 4096 Feb 10 14:47 b -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py /home/andrea/test_ns/a.b/a/b: total 12 -rw-r--r-- 1 andrea andrea 25 Feb 10 14:36 api.py -rw-r--r-- 1 andrea andrea 153 Feb 10 14:37 api.pyc -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py /home/andrea/test_ns/a.c: total 8 drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:47 a -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py /home/andrea/test_ns/a.c/a: total 8 drwxr-xr-x 2 andrea andrea 4096 Feb 10 14:47 c -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py /home/andrea/test_ns/a.c/a/c: total 12 -rw-r--r-- 1 andrea andrea 20 Feb 10 14:36 api.py -rw-r--r-- 1 andrea andrea 148 Feb 10 14:38 api.pyc -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py So this test.py works perfectly: import sys sys.path.insert(0, 'a.c') sys.path.insert(0, 'a.b') from a.b import api as api_ab from a.c import api as api_ac While just mixing the order: import sys sys.path.insert(0, 'a.b') from a.b import api as api_ab sys.path.insert(0, 'a.c') from a.c import api as api_ac Doesn't work anymore [andrea@precision test_ns]$ python2 test.py Traceback (most recent call last): File "test.py", line 7, in from a.c import api as api_ac ImportError: No module named c Am I missing something/doing something stupid?