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


Groups > comp.lang.python > #82172

Re: module import questions and question about pytest and module imports

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 <ian.g.kelly@gmail.com>
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&gt;': 0.22; '&gt;': 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 <CAPti5iPBG_YiG-ZUu_ZQD8qdg91Oq_6CXoJ-9t9vRFwtNYL4rA@mail.gmail.com>
References <CAPti5iMacuhtNhGg_YkqdkW+X36R6bzRTo_RWn-KMq0CwczAOQ@mail.gmail.com> <54847FAF.8040006@davea.name> <CAPti5iPBG_YiG-ZUu_ZQD8qdg91Oq_6CXoJ-9t9vRFwtNYL4rA@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Mon, 8 Dec 2014 19:22:18 -0700
Subject Re: module import questions and question about pytest and module imports
To Python <python-list@python.org>
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 <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.16756.1418091788.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Sun, Dec 7, 2014 at 9:50 AM, sam pendleton <samp4040@gmail.com> 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.

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


Thread

Re: module import questions and question about pytest and module imports Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-08 19:22 -0700

csiph-web