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


Groups > comp.lang.python > #53733

Re: Importing Definitions

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <skip.montanaro@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'imported': 0.09; 'subtle': 0.09; 'things,': 0.09; 'cc:addr:python-list': 0.11; '"from': 0.16; 'bugs.': 0.16; 'from:addr:pobox.com': 0.16; 'from:addr:skip': 0.16; 'special.': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'sender:addr:gmail.com': 0.17; 'module': 0.19; 'work,': 0.20; 'import': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; "aren't": 0.24; 'skip': 0.24; 'cc:2**0': 0.24; 'source': 0.25; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'maybe': 0.34; 'common': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'doing': 0.36; 'clear': 0.37; 'name': 0.63; 'more': 0.64; 'forth': 0.81; 'imagining': 0.84; 'can!': 0.91; 'from.': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=h7eujnhcsvuXawTrbEmqHzAUvJrqtp8wtz1OfOqg6HM=; b=w2CiRugEC/+es+TwjFcmdU1dHGrRQlS/r7YztfC3VcppjLvxYwV2M5L7s32tZs4aa6 uYQzLYMADrOMWBBR9F8LjYjjxQm0Q4YIJCXWEwdltYsbzhXdfljEnwCVlK/c3oY3ApD6 YdQzBg0X3Ipi5ky1Stw2Ak/oK+IqeO2KUwOo+n+GD8aWcSaO9Cgc7O+RF3l8JUn8kKUV zmXfpbXjnFtPEpA15zZnXhDoPkWblYqSw5tpp40WIlgNnZodFDaR5kmJ3H/J6WgWsern sgSCh8yCIUQl9ABt0u+oODAhf15yWaSLFO1WjzKr6cxFY5vHMCBX76IzPzi1QT11rqaG hIWA==
MIME-Version 1.0
X-Received by 10.52.34.109 with SMTP id y13mr83705vdi.8.1378404416416; Thu, 05 Sep 2013 11:06:56 -0700 (PDT)
Sender skip.montanaro@gmail.com
In-Reply-To <5228bf2d$0$29988$c3e8da3$5496439d@news.astraweb.com>
References <28b859f6-f14b-49d2-9e14-5d3febd33441@googlegroups.com> <mailman.91.1378385806.5461.python-list@python.org> <5228bf2d$0$29988$c3e8da3$5496439d@news.astraweb.com>
Date Thu, 5 Sep 2013 13:06:56 -0500
X-Google-Sender-Auth 1XdfG8x3SJUCKFImPlxZ6v0bTgo
Subject Re: Importing Definitions
From Skip Montanaro <skip@pobox.com>
To "Steven D'Aprano" <steve+comp.lang.python@pearwood.info>
Content-Type text/plain; charset=UTF-8
Cc Python <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 <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.103.1378404425.5461.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1378404425 news.xs4all.nl 15947 [2001:888:2000:d::a6]:36579
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:53733

Show key headers only | View raw


>> You can! Any name will work, functions aren't special.
>>
>> from module1 import method1, A, B, C, D, E
>
> Better practice is to use:
>
> import module1
> print module1.A
> print module2.B
>
> and so forth since that makes it far more clear what you are doing and
> where they come from. But it's not compulsory.

Maybe I'm imagining things, but I think it's pretty common to see some
big-ass modules imported using "from module import *".  While people
may think that's expedient, I think it can often be the source of
subtle bugs.

Skip

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


Thread

Importing Definitions Azureaus <lo0446@my.bristol.ac.uk> - 2013-09-05 05:39 -0700
  Re: Importing Definitions Chris Angelico <rosuav@gmail.com> - 2013-09-05 22:50 +1000
    Re: Importing Definitions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-05 17:28 +0000
      Re: Importing Definitions Skip Montanaro <skip@pobox.com> - 2013-09-05 13:06 -0500
      Re: Importing Definitions Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-09-06 11:05 +0100
  Re: Importing Definitions Peter Otten <__peter__@web.de> - 2013-09-05 15:00 +0200
  Re: Importing Definitions Ethan Furman <ethan@stoneleaf.us> - 2013-09-05 05:56 -0700
  Re: Importing Definitions Azureaus <lo0446@my.bristol.ac.uk> - 2013-09-06 02:10 -0700

csiph-web