Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2a.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.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'package,': 0.03; 'importing': 0.05; 'subject:Python': 0.06; '21,': 0.07; 'python3': 0.07; 'valueerror:': 0.09; "'from": 0.16; 'attempted': 0.16; 'imports': 0.16; 'mkdir': 0.16; 'subject:dependencies': 0.16; 'subject:import': 0.16; 'top-level': 0.16; 'wrote:': 0.18; 'import': 0.22; 'separate': 0.22; 'creating': 0.23; 'package.': 0.24; "i've": 0.25; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'tim': 0.29; 'relative': 0.30; 'message- id:@mail.gmail.com': 0.30; '"",': 0.31; 'chase': 0.31; 'file': 0.32; '(most': 0.33; 'fri,': 0.33; 'not.': 0.33; 'subject:the': 0.34; 'beyond': 0.35; 'received:google.com': 0.35; 'done': 0.36; 'nov': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'subject:"': 0.60; 'break': 0.61; 'name': 0.63; 'happen': 0.63; 'within': 0.65; 'touch': 0.74; 'skip:$ 10': 0.81; 'indirect': 0.84; 'overloading': 0.84; 'subject:history': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=AFJSJuVkhLX9CjVRl3x+NnprVYXvJ4rdS575K+ZncLU=; b=rSlRXLLl3JXnt9d1J393f3lD0sDKV59aCUn0ceb5FFI9lx/Jjg41ZnjHB7YY5nHCBN d826udGX9OCy2WkzAUHQF+BpRVIrBOkqxtLE+D7lidH2gU3oyLBapHymJl0RAlMw+7pi VBhgqDUdEWhXZbYstKuIkncn2kqx2aYjbgQ3nH/hIvLJRdgN9zg3ggdf7lTJYQ/4Vlke U0qR9oH3w067uc2QJ/6QvjNbLkQuy/nXUNcc840nMfdcDYc5Lp9bSUb6O5HQhfkk2l7D 1Cu2lHJ8pMTWCkIjcbLwA/JSBLh8QjUMZUOeuI2pA+/9PGTpVcmQSdhWGbio/QT2VB9Y WsuA== X-Received: by 10.68.111.161 with SMTP id ij1mr9750149pbb.10.1416591804511; Fri, 21 Nov 2014 09:43:24 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20141121101255.6a07dfa4@bigbox.christie.dr> References: <066c46c8-a04d-4489-b15a-b603c1b1818b@googlegroups.com> <8661e407-4472-4208-97c2-f666f6502c67@googlegroups.com> <2886a22f-54f6-4d54-b064-911fc0f03ed2@googlegroups.com> <20141121101255.6a07dfa4@bigbox.christie.dr> From: Ian Kelly Date: Fri, 21 Nov 2014 10:42:44 -0700 Subject: Re: PyWart: "Python's import statement and the history of external dependencies" To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416591808 news.xs4all.nl 2842 [2001:888:2000:d::a6]:47401 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81231 On Fri, Nov 21, 2014 at 9:12 AM, Tim Chase wrote: > The only time I've been stung by name overloading is in the indirect > case of creating a local email.py file and then importing smtplib > only to have things break in unforeseen ways. If smtplib used > relative imports for $STDLIB/email.py I suspect it would ameliorate > that particular issue for me. Relative imports are based on package namespaces and can only be done within a package. There's no way to do a relative import from a separate top-level package, whether they happen to be found in the same directory or not. $ mkdir p1 $ touch p1/__init__.py $ echo 'from ..p2 import m2' > p1/m1.py $ mkdir p2 $ touch p2/__init__.py $ touch p2/m2.py $ python3 -c 'import p1.m1' Traceback (most recent call last): File "", line 1, in File "/home/ikelly/p1/m1.py", line 1, in from ..p2 import m2 ValueError: attempted relative import beyond top-level package