Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.01; 'situation.': 0.04; 'sys': 0.05; 'names.': 0.07; 'paths': 0.07; 'subject:changing': 0.07; 'imported.': 0.09; 'namespace': 0.09; 'api': 0.09; 'additions': 0.16; 'come?': 0.16; 'cc:addr:python- list': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.21; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'earlier': 0.23; 'ones.': 0.23; 'fine': 0.24; 'guess': 0.26; 'module': 0.26; 'import': 0.27; 'cc:addr:gmail.com': 0.28; 'example': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'fails,': 0.30; 'specifically': 0.30; 'message-id:@gmail.com': 0.31; 'quite': 0.31; 'there': 0.33; 'header:User-Agent:1': 0.33; 'anything': 0.34; 'symbol': 0.34; 'problem.': 0.35; 'probably': 0.35; 'something': 0.35; 'received:209.85.214': 0.36; 'cc:2**1': 0.36; 'contributing': 0.37; 'received:10.0.0': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'using': 0.37; 'received:209.85': 0.38; 'should': 0.38; 'absolute': 0.39; 'received:209': 0.39; 'change': 0.40; "you've": 0.61; 'your': 0.61; 'real-world': 0.64; 'here': 0.64; 'special': 0.66; 'difference.': 0.84 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=i3yOq392nSMZ4lzxi7yuddLOLZ3eiJ01eQzVnyQl6Aw=; b=tAz46WznNVX6jntIdZugVSJ9OvT7HIEtC3Et0CWN9hSnjSyLjOOFo5/YM4EsZLoL2Z 3E/Rsr8aHHjajnWGfKZ9ow/7pE+sOdzC3fzIQ2nzeGAjL0Wf/r6r1cyrTWrMOBd/O31V zyG6R5KJlFp5+v6rbtaU8C8ywgPenXNnWVurQ= Date: Fri, 10 Feb 2012 15:14:23 +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> <4F352EE8.1030101@gmail.com> <4F353274.704@davea.name> In-Reply-To: <4F353274.704@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: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328886868 news.xs4all.nl 6851 [2001:888:2000:d::a6]:46514 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20167 On 02/10/2012 03:06 PM, Dave Angel wrote: > > Yes, you've got periods in your directory names. A period means > something special within python, and specifically within the import. > > When you say from a.c import api > > You're telling it: from package a get module c, and from there > impoort the symbol api > > But package a has no module c, so it complains. > > > In an earlier message you asserted you were using all absolute paths > in your additions to sys.path. Here you're inserting relative ones. > How come? > Well yes I have periods, but that's also the real-world situation. We have many directories that are contributing to the same namespace in the same superdirectory which should not interfere, so it was decided to give this naming. It would be quite hard to change I guess and I have to prove that this is problem. I renamed everything and this import sys from os import path sys.path.insert(0, path.abspath('ab')) from a.b import api as api_ab sys.path.insert(0, path.abspath('ac')) from a.c import api as api_ac still fails, so the period in the name is not the problem. Also absolute or relative paths in this small example doesn't make any difference. Adding all the paths in one go works perfectly fine anyway, so I probably have to make sure I add them *all* before anything is imported. If there are better solutions I would like to hear them :)