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


Groups > comp.lang.python > #100522

Re: does the order in which the modules are placed in a file matters ?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: does the order in which the modules are placed in a file matters ?
Date Thu, 17 Dec 2015 03:49:18 +1100
Lines 21
Message-ID <mailman.18.1450284561.30845.python-list@python.org> (permalink)
References <CACT3xuW5hdCUDaO4i-Fd8583j9CC0ATm3xHWYsqEXcbuW8_pgw@mail.gmail.com> <CAPTjJmqskNGthW9n4n_uP_6DbPeH-u5AoqKjxrV3vWg37V_0vw@mail.gmail.com> <ef78ab45c3944cf48d373d32947b9816@seaexchmbx03.olympus.F5Net.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de amSl56ImC0UeNaDQE1r8EAAjS2CPDWL4gFU/0l2meybw==
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'subject:file': 0.07; 'cc:addr:python-list': 0.09; 'imports': 0.09; 'subject:modules': 0.09; 'subject:which': 0.09; 'file,': 0.15; 'thu,': 0.15; '"*"': 0.16; '(well,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:matters': 0.16; 'wrote:': 0.16; 'duplicate': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'referring': 0.22; 'see:': 0.22; 'am,': 0.23; 'dec': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'module': 0.25; "doesn't": 0.26; 'subject: ?': 0.27; 'message-id:@mail.gmail.com': 0.27; 'dan': 0.29; 'strongly': 0.30; 'generally': 0.32; 'url:python': 0.33; 'done,': 0.33; 'wrap': 0.33; 'received:google.com': 0.35; 'star': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'modules': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'being': 0.37; 'there,': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'names': 0.38; 'end': 0.39; 'why': 0.39; 'sure': 0.39; 'subject:the': 0.39; 'some': 0.40; 'more': 0.63; 'information': 0.63; 'places': 0.64; 'packages,': 0.66; 'chrisa': 0.84; 'confusion.': 0.84; 'intending': 0.84; 'to:none': 0.91; 'promised': 0.91; 'url:tutorial': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=bBNzHUjAG8IPOTx4ZxjCcWceiYn7fECXqxPtT350cnA=; b=WNYgHmkybc5+VgqZjuvvLC0FvT2y2AW1vXqeZMg+OjIWqPiGkM42tZTsIMZM2WhtAH vYvy1ptg1pGS2yKdhwXw7HoM680jKqfyDtqftOwj6bMhf2rA4g8nhydSOJNVkTH8yj1m ebqcDXsn/6H0PidBDbTO1abdHrtgmUbDrOvwHfzM4GH74A8fNuGXFJ0SMqFPOgHTicNt zPz8+Wi9lqaRO47N2aDlDCMu6Fb5XmnnTTTf1t7vu5/rDtTsZ9Jjhfg9cpLbPCWAfu8i qwaHMib3VE0kvON4pUa7ymCbg9WPASSJ4xu5uDDbnKEj2GsGa69BD1uqVT075xbNMhZ4 fhFQ==
X-Received by 10.50.82.70 with SMTP id g6mr3410886igy.13.1450284558269; Wed, 16 Dec 2015 08:49:18 -0800 (PST)
In-Reply-To <ef78ab45c3944cf48d373d32947b9816@seaexchmbx03.olympus.F5Net.com>
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>
Xref csiph.com comp.lang.python:100522

Show key headers only | View raw


On Thu, Dec 17, 2015 at 3:42 AM, Dan Strohl <D.Strohl@f5.com> wrote:
> For the general modules it doesn't matter, however using if you are using any non-standard packages, and If there are duplicate names in any of the modules and if you import them with a "*" (as some packages suggest), it can cause you to end up referring to an object you were not intending to.
>
> [chomp]
>
> Note, using * is dis-recommended, though pretty often done, for more information on using *, see: https://docs.python.org/2/tutorial/modules.html#importing-from-a-package

This is exactly why (well, one of the reasons why) star imports are
generally not recommended. There are a small number of modules that
have promised to keep their namespaces clean in order to make this
viable, but even there, it has issues of confusion. There are a few
good places to use star imports, such as when you wrap one module in
another; I would STRONGLY recommend against using two star imports in
a single file, without being VERY sure of what you're doing.

ChrisA

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


Thread

Re: does the order in which the modules are placed in a file matters ? Chris Angelico <rosuav@gmail.com> - 2015-12-17 03:49 +1100

csiph-web