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


Groups > comp.lang.python > #96259

Re: Question about import

Path csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!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.034
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'needed,': 0.05; 'subject:Question': 0.05; 'thu,': 0.15; 'missing?': 0.16; 'module?': 0.16; 'subject:import': 0.16; 'wrote:': 0.16; 'project,': 0.18; '2015': 0.20; 'explicit': 0.22; 'sep': 0.22; 'am,': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'module': 0.25; 'wonder': 0.27; 'question': 0.27; 'message- id:@mail.gmail.com': 0.27; "skip:' 10": 0.28; 'fine': 0.28; 'if,': 0.29; 'that.': 0.30; 'another': 0.32; 'that,': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'modules': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'one,': 0.37; 'thought': 0.37; 'names': 0.38; 'rather': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'different': 0.63; 'qualified': 0.63; 'you.': 0.64; 'reuse': 0.66; "they're": 0.66; 'frank': 0.72; 'to:name:python': 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=12GuxCB0h91/xHA/rFFCYHEg64LqLeY3Y2O1JgDWOps=; b=w+E0jsRwml77Xr1mKYALvpPXEJBgHj9aoFhPUsAFF2y5kHMDVFdJsNvbP5+xVMDo0j W/OrJBsScRWxNHc7ml4G5MujMwkDU1fj1XcBhroK98QEjC0OQkBjG6DcIcDeoc26Md/v vO/QlZfP8ahLyvm9hO3rLBGG6Efivsn3Xszcqfnfh22Wgf9Z8fMcKYyGi8vDuSwWOmN9 5xLSqzM7Omd9nMiHLnOGnZWE2NAhCTA3i7agtiCanL2yOj+vRJj8vu1DptMOn8gTQis4 3IxuNcwzUpOiZpXkjHB5IZCu+aH488HE2I/d9KXuPTtow4Gp4GXN7bjCj9qycKPn85bF Ihag==
X-Received by 10.129.45.194 with SMTP id t185mr48365349ywt.111.1441894679096; Thu, 10 Sep 2015 07:17:59 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <msrah1$sju$1@ger.gmane.org>
References <msrah1$sju$1@ger.gmane.org>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Thu, 10 Sep 2015 08:17:19 -0600
Subject Re: Question about import
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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.316.1441894687.8327.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1441894687 news.xs4all.nl 23776 [2001:888:2000:d::a6]:46462
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:96259

Show key headers only | View raw


On Thu, Sep 10, 2015 at 1:12 AM, Frank Millman <frank@chagford.com> wrote:
> That makes me wonder if, in my project, I can import all modules inside
> 'start.py', and then just use 'import package_name' inside each module?

You can, but for readability and reuse I think it's better to be
explicit in each module and import the fully qualified module names
that are needed, rather than relying on some other module to import
them for you.

> Another question - I thought that, because aa.py and bb.py are in different
> sub-directories, I would have to set them up as packages by adding
> '__init__.py' to each one, but it works fine without that. What am I
> missing?

That surprises me also, but I suspect it's because they're
subdirectories of the current working directory rather than packages
found on the sys.path.

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


Thread

Re: Question about import Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-10 08:17 -0600

csiph-web