Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:module': 0.09; 'subject:question': 0.10; "wouldn't": 0.14; 'posted': 0.15; 'hierarchy': 0.16; 'imports': 0.16; "package's": 0.16; 'subject:import': 0.16; 'subject:questions': 0.16; 'such,': 0.16; 'sys.path': 0.16; 'top-level': 0.16; 'wrote:': 0.18; 'module': 0.19; 'seems': 0.21; 'import': 0.22; 'email addr:gmail.com>': 0.22; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'absolute': 0.30; 'besides': 0.30; 'dec': 0.30; 'relative': 0.30; 'statement': 0.30; 'message-id:@mail.gmail.com': 0.30; 'file': 0.32; "can't": 0.35; 'received:google.com': 0.35; 'work?': 0.38; 'to:addr:python-list': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; 'system.': 0.39; 'sam': 0.68; 'off,': 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=mPPCOvyF77aOrKuLyOkIhQnm+U+AYFY0D+DEbWkc+vw=; b=yjMwCGhn/BtSAzLG/c2QvuaectFrb1IrW+13WbuSAKSUdb/gHbySC9lk6nXBRqY4G+ tbM4NQtbLCCoc5yk+LwJvPVTIqksqaWYJB/5TX6vQ2kJPI8irzBZl1XRG5wavG26HoOC uTCHPSl5I4vlX7uaB/0KxHknnhxOeIr2CvBSMIUl7hBSQo1rGjamQ8cSib+Xaf5WRGni vzfZ3AAySCBuRtBRVlyyHVhXMyAatS3XorqT1NC6p9ZUE1YuHdzzrh05+i5/+JVtFJsL 9bw4QQCFNG+yHo4I1fBwHi/3CDF70YIt2EFsQtvv/2t7zEe20QO/6kAAAP0F1c81gDXt eJJA== X-Received: by 10.68.170.130 with SMTP id am2mr876096pbc.156.1418091778882; Mon, 08 Dec 2014 18:22:58 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <54847FAF.8040006@davea.name> From: Ian Kelly Date: Mon, 8 Dec 2014 19:22:18 -0700 Subject: Re: module import questions and question about pytest and module imports To: Python Content-Type: multipart/alternative; boundary=047d7b6da96ebd424f0509bf3889 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1418091788 news.xs4all.nl 2900 [2001:888:2000:d::a6]:41674 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82172 --047d7b6da96ebd424f0509bf3889 Content-Type: text/plain; charset=UTF-8 On Sun, Dec 7, 2014 at 9:50 AM, sam pendleton wrote: > Having to put the garage package on the sys.path seems a little off, > why wouldn't relative imports work? Relative imports are relative to a package's hierarchy of namespaces, not relative to the file system. As such, you can't perform a relative import of a module that isn't in the same top-level package (and besides this, the import statement that you posted was an absolute import anyway). All top-level packages have to be on sys.path, or the import system won't be able to find them. --047d7b6da96ebd424f0509bf3889 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Sun, Dec 7, 2014 at 9:50 AM, sam pendleton <samp4040@gmail.com> wrote:
> Ha= ving to put the garage package on the sys.path seems a little off,
> = why wouldn't relative imports work?

Relative imports are re= lative to a package's hierarchy of namespaces, not relative to the file= system. As such, you can't perform a relative import of a module that = isn't in the same top-level package (and besides this, the import state= ment that you posted was an absolute import anyway).

All top-level packages have to be on sys.path, or the import system won&= #39;t be able to find them.
--047d7b6da96ebd424f0509bf3889--