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


Groups > comp.lang.python > #51514

Re: import syntax

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <joshua.landau.ws@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.015
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'importing': 0.05; 'root': 0.05; 'sys': 0.07; 'collier': 0.09; 'exit': 0.09; 'recommends': 0.09; 'sure,': 0.09; 'cc:addr:python-list': 0.11; '"from': 0.16; '-tkc': 0.16; 'cleanly': 0.16; 'pep8': 0.16; 'subject:import': 0.16; 'things"': 0.16; 'things&quot;': 0.16; '\xc2\xa0i': 0.16; 'sender:addr:gmail.com': 0.17; 'fix': 0.17; 'wrote:': 0.18; 'bit': 0.19; 'module': 0.19; '>>>': 0.22; 'import': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'flows': 0.24; 'tend': 0.24; 'cc:2**0': 0.24; 'sort': 0.25; 'this:': 0.26; 'asking': 0.27; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; 'said,': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '(which': 0.31; 'code': 0.31; 'too.': 0.31; '>>>>': 0.31; 'chase': 0.31; 'everywhere': 0.31; 'os,': 0.31; 'another': 0.32; 'skip:& 30': 0.33; 'johnson': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; "i'll": 0.36; 'so,': 0.37; 'list': 0.37; 'pm,': 0.38; 'read': 0.60; 'dave': 0.60; 'up,': 0.60; 'profile': 0.61; 'reach': 0.63; 'july': 0.63; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'worth': 0.66; 'hours': 0.66; 'advantages': 0.68; 'further,': 0.74; 'repeat': 0.74; 'yourself': 0.78; 'comment.': 0.84; 'optimisation': 0.84; 'premature': 0.84; 'quicker': 0.84; 'angel': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=VnDN4/ReIg6ejQzXzegNkzMV+Z97CYatHIzCv9az0QE=; b=zpW+MglYtr39CjB1cd9ceoT8P6vHHH2Ew3mA8YoePARShB1B6/2U8HSG/I6cFY9w6k xXHfNxXtjUsuECeuXpXPtbhmW7SB8fD54FRU42F7DU/Dsc5/wS8jVcv2T0sfpMn1aQTb LH2edPWxCy62EjFGzRaBoCTRz0bvqp39g/JCyOOg/bVMLBN3uAH27e/9IxFWzzRwJfNv U6pKZpoExWZ4ueuqGIiQvfS+CHbaP/j9g6tyeFF7gw/ejj+SlsAi+PkZtAGHhFo6VXYK 8NFC90cz8iSWlH1u7T0gwO2jMNlC1yd8r3fmnhGeKFXXvcNVL+wbQDHE8Lwci9OlFb/W q6Qw==
X-Received by 10.152.45.65 with SMTP id k1mr27606944lam.78.1375137497664; Mon, 29 Jul 2013 15:38:17 -0700 (PDT)
MIME-Version 1.0
Sender joshua.landau.ws@gmail.com
In-Reply-To <51F6CF36.7080702@Gmail.com>
References <51F6C720.2020404@Gmail.com> <kt6i57$2ku$1@ger.gmane.org> <20130729152051.46003bcf@bigbox.christie.dr> <51F6CF36.7080702@Gmail.com>
From Joshua Landau <joshua@landau.ws>
Date Mon, 29 Jul 2013 23:37:37 +0100
X-Google-Sender-Auth 9VfYr6bzVHp3Li1aX0pNXZm7WYk
Subject Re: import syntax
To Devyn Collier Johnson <devyncjohnson@gmail.com>
Content-Type multipart/alternative; boundary=001a11c1b7ae10d21204e2ae26ff
Cc Python Mailing List <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.5281.1375137506.3114.python-list@python.org> (permalink)
Lines 126
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1375137506 news.xs4all.nl 15906 [2001:888:2000:d::a6]:40640
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:51514

Show key headers only | View raw


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

On 29 July 2013 21:23, Devyn Collier Johnson <devyncjohnson@gmail.com>wrote:

>
> On 07/29/2013 04:20 PM, Tim Chase wrote:
>
>> On 2013-07-29 16:09, Dave Angel wrote:
>>
>>> On 07/29/2013 03:48 PM, Devyn Collier Johnson wrote:
>>>
>>>> The PEP8 recommends importing like this:
>>>>
>>>> import os
>>>> import re
>>>>
>>>> not like this:
>>>>
>>>> import os, re
>>>>
>>> I got a bit further, and if I'm only using a couple of functions
>>> from the import, I'll list them in the comment.
>>>
>> If I just plan to use a small subset, I tend to reach for the
>>
>>    from sys import stdout, stderr, exit
>>
>> sort of syntax.  I find it makes my code read a bit more cleanly than
>> having to type "sys.stderr.write(...)" everywhere but is still pretty
>> readable.
>>
>> -tkc
>>
>>
>>  So, there are no advantages or disadvantages when disregarding
> readability?


Sure, just as one light is no brighter or dimmer than another when
disregarding luminosity.

As people have said, it improves diffs as well. It flows quicker into the
"from module import things" form (which I oft prefer), too.

When asking these questions, ask yourself "why would it *compile*
differently? It wouldn't. Plus, premature optimisation is the root of all
evil.

1) Write your code
2) If it's slow:
2a) Do you have time? If so:
2b) Is it important to speed up, or is the slowness not worth spending the
hours fixing?
2c) Profile it to see what's actually slow
2d) Realise that the slow part is not what you thought it was
2e) Fix the bit that's slow (and nothing else)
2f) Repeat from 2
3) Write some more code

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


Thread

Re: import syntax Joshua Landau <joshua@landau.ws> - 2013-07-29 23:37 +0100
  Re: import syntax Neil Cerutti <neilc@norwich.edu> - 2013-07-30 13:03 +0000

csiph-web