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


Groups > comp.lang.python > #41953

Re: import in Python3.3

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <pconnell@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.032
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'ambiguity': 0.09; 'pep': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '328': 0.16; 'collections': 0.16; 'exist.': 0.16; 'subject:import': 0.16; 'sys.path': 0.16; 'language': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'import': 0.22; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In- Reply-To:1': 0.27; 'url:code': 0.29; 'relative': 0.30; 'asked': 0.31; '-0700,': 0.31; 'probably': 0.32; 'something': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'impression': 0.36; "didn't": 0.36; 'charset:us-ascii': 0.36; 'should': 0.36; 'error.': 0.37; 'searching': 0.37; 'wrong': 0.37; 'content- disposition:inline': 0.62; 'places': 0.64; 'url:p': 0.64; 'mar': 0.68; '26,': 0.68; 'wish': 0.70; 'received:86': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=WyrNTLZW8gyQcu0IaeZ80D3A9X5uufJS6wOaGLQQyCk=; b=ezqzD6Rirt+HNYnkU1QHnUM416NW0jF+qTZbfrWbIvmuwobAnM3cSas7LHivVo4IBt ngkOusIjP4oaJSV/0HVe3gw9K8vp6FjvnzpV3z1n+Ifc+6pmeUai9hlBS+1Cm/XBrNsZ AKBSn58DQM80Tn6VS4ghzuJ09pdYLE6d2dO5PX4fO83FmJjiRrWj/XVCNvEunbdV+dRk MUHQyfm0qvN/gu2M/xr6jEOMDI8ipviqdsJ1sVxJK4x59WmogCst70NR72mT949vC/ik SRho5w8uxJQtor2yxeOWfxC1TIL8t/9qzTAR6XEEH2T8Gvbjw5XYZ05qjHKWgSbU6ioR mV4w==
X-Received by 10.194.71.241 with SMTP id y17mr27341682wju.28.1364332825688; Tue, 26 Mar 2013 14:20:25 -0700 (PDT)
Date Tue, 26 Mar 2013 21:16:57 +0000
From Phil Connell <pconnell@gmail.com>
To rocky <rocky@gnu.org>
Subject Re: import in Python3.3
References <kio19e$5e2$1@ger.gmane.org> <mailman.3722.1364281502.2939.python-list@python.org> <2b893e00-8fac-4733-b07d-2041af850540@googlegroups.com>
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
In-Reply-To <2b893e00-8fac-4733-b07d-2041af850540@googlegroups.com>
User-Agent Mutt/1.5.21 (2010-09-15)
Cc python-list@python.org
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3777.1364332827.2939.python-list@python.org> (permalink)
Lines 16
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1364332827 news.xs4all.nl 6890 [2001:888:2000:d::a6]:45167
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41953

Show key headers only | View raw


On Tue, Mar 26, 2013 at 08:37:00AM -0700, rocky wrote:
> And again, I get the impression that for the use case asked about, there isn't much ambiguity. If I am in mypackage.foo and I want to access mypackage.collections I should be able to say something like that without ambiguity or that much inference or directory searching. If mypackage.colletions is not found inside the same directory as mypackage.foo, often I DON'T WANT Python to helpfully go searching around other places for it which sys.path will do. Instead what I probably want is Python to give me an error. 
> 
> So again I come to import_relative, http://code.google.com/p/pyimport-relative/.  And again, I wish this package didn't have to exist.

What's wrong with PEP 328 relative imports?

In mypackage.foo, use

    from . import collections

to import mypackage.collections.


This has been part of the language since ~2.5

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


Thread

Re: import in Python3.3 Terry Reedy <tjreedy@udel.edu> - 2013-03-26 03:04 -0400
  Re: import in Python3.3 rocky <rocky@gnu.org> - 2013-03-26 08:37 -0700
    Re: import in Python3.3 Phil Connell <pconnell@gmail.com> - 2013-03-26 21:16 +0000
    Re: import in Python3.3 Rocky Bernstein <rocky@gnu.org> - 2013-03-26 18:24 -0400
    Re: import in Python3.3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-26 23:06 +0000
      Re: import in Python3.3 rocky <rocky@gnu.org> - 2013-03-26 17:33 -0700
  Re: import in Python3.3 rocky <rocky@gnu.org> - 2013-03-26 08:37 -0700

csiph-web