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


Groups > comp.lang.python > #51520

Re: import syntax

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <devyncjohnson@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.030
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'importing': 0.05; 'root': 0.05; 'sys': 0.07; 'collier': 0.09; 'exit': 0.09; 'recommends': 0.09; 'sure,': 0.09; '"from': 0.16; '-tkc': 0.16; 'cleanly': 0.16; 'pep8': 0.16; 'subject:import': 0.16; 'things"': 0.16; '\xc2\xa0i': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'bit': 0.19; 'module': 0.19; 'import': 0.22; 'email addr:gmail.com&gt;': 0.22; 'header:User-Agent:1': 0.23; 'flows': 0.24; 'tend': 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; "i'm": 0.30; '(which': 0.31; 'code': 0.31; 'received:10.0.0': 0.31; 'too.': 0.31; 'chase': 0.31; 'everywhere': 0.31; 'os,': 0.31; 'another': 0.32; 'johnson': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; "i'll": 0.36; 'received:10.0': 0.36; 'so,': 0.37; 'list': 0.37; 'received:10': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'read': 0.60; 'dave': 0.60; 'up,': 0.60; 'profile': 0.61; 'reach': 0.63; 'july': 0.63; 'more': 0.64; '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=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=m/ye/H/4RRooxAx/L2q95AfaJzJjf+JfrLdPCpq/QMk=; b=lmpCvFsP1tKETjzsGY49AusMawTq3KmwZYiQAYNYzbdf/NjCH95xvgYYMsZKSEV9qi l75+qsTx6VjCfSSB+alXdTx5b9DYYCoCipvWDe4RIs7hluxOef6tGPZ964DZVd+olEwN 6jdGcUOVIybfHsFOxlD6nqi9Jd/JlendzUIw3A8lDHrHOJAkwXJ8kzSx0drjWahFIMH/ 2b2MXWmV4t9IHrQCp7Gs6sc52JKNEKlsaE9awgp+Apvp9fGBqP1hRWcQ8OLrv1YQKaZF VcX1lSsjfeeNuGxeNOYCjIW1sJwVQgXqKFaDzZifpZz6caevZNAfjUVvPpJe0Kgd2Cku 1zkw==
X-Received by 10.236.122.6 with SMTP id s6mr29059593yhh.158.1375140250385; Mon, 29 Jul 2013 16:24:10 -0700 (PDT)
Date Mon, 29 Jul 2013 19:24:01 -0400
From Devyn Collier Johnson <devyncjohnson@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7
MIME-Version 1.0
To Python Mailing List <python-list@python.org>
Subject Re: import syntax
References <51F6C720.2020404@Gmail.com> <kt6i57$2ku$1@ger.gmane.org> <20130729152051.46003bcf@bigbox.christie.dr> <51F6CF36.7080702@Gmail.com> <CAN1F8qU9WQS-eS0PPAKhkLz4RYDG9JHX2S3iEq9EbF9BymCnkQ@mail.gmail.com>
In-Reply-To <CAN1F8qU9WQS-eS0PPAKhkLz4RYDG9JHX2S3iEq9EbF9BymCnkQ@mail.gmail.com>
Content-Type multipart/alternative; boundary="------------040906020504050809020500"
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.5285.1375140259.3114.python-list@python.org> (permalink)
Lines 181
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1375140259 news.xs4all.nl 15902 [2001:888:2000:d::a6]:34719
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:51520

Show key headers only | View raw


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

On 07/29/2013 06:37 PM, Joshua Landau wrote:
> On 29 July 2013 21:23, Devyn Collier Johnson <devyncjohnson@gmail.com 
> <mailto: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
Joshua, nice work-flow instructions.

Mahalo,

DCJ

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


Thread

Re: import syntax Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-29 19:24 -0400

csiph-web