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


Groups > comp.lang.python > #61205

Re: One liners

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <joel.goldstick@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'programmer': 0.03; 'operator': 0.03; 'assigning': 0.09; 'dan': 0.09; 'reformat': 0.09; 'cc:addr:python-list': 0.11; 'django': 0.11; 'wrote': 0.14; 'mostly': 0.14; '"if"': 0.16; 'cc:name:python list': 0.16; 'clear.': 0.16; 'deferred': 0.16; 'imo.': 0.16; 'of)': 0.16; 'rent': 0.16; 'sane': 0.16; 'ternary': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'trying': 0.19; 'written': 0.21; 'seems': 0.21; 'machine': 0.22; 'code,': 0.22; 'example': 0.22; 'coding': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'sort': 0.25; '&gt;': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'michael': 0.29; 'compared': 0.30; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; 'lines': 0.31; 'fixing': 0.31; 'figure': 0.32; 'quite': 0.32; 'url:python': 0.33; 'fri,': 0.33; 'style': 0.33; 'totally': 0.33; 'skip:s 30': 0.35; 'something': 0.35; 'convert': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'that!': 0.36; 'url:listinfo': 0.36; 'useful': 0.36; 'url:org': 0.36; 'should': 0.36; 'skip:& 10': 0.38; 'pm,': 0.38; 'aside': 0.39; 'bad': 0.39; 'sure': 0.39; 'enough': 0.39; 'url:mail': 0.40; 'skip:u 10': 0.60; 'read': 0.60; 'most': 0.60; 'new': 0.61; "you're": 0.61; 'back': 0.62; 'times': 0.62; 'pick': 0.64; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'to,': 0.72; 'physical': 0.72; 'subject:One': 0.74; 'yourself': 0.78; 'itself?': 0.84; 'joel': 0.91; 'urls,': 0.91; '2013': 0.98
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:to :cc:content-type; bh=lFt2onrcGThN5Y3fNvd4uTQKTy4KQMvQ/q0LMc7zPu8=; b=zeFPsJNXq747MZmLqTeqmRLdDVrFVzVmq9AHpXtwhvqjwq97NzCNrrF12juPKRaHwu 6db2QtstZ6HAjLjAk86eBXkYRYezDIHN6wZVx22lVvcQRHANaMvQUtSV5v6CkztXskzz vf1P5soK/tcMNh7NlzUOp8PAq6FyEu+GCWnFbxcF04foEuHgQy4zNfsg15FqcqNtrDab b0RLTkb8WJpBZ+6uDcTQSo0EYYT5hc00ZmPMUv5CbzoCDz+GMkBLGouN7V6TaPyMXg5M TK8XMeC9RdMrZoAFcx6fBKzy6iuG4CqCK4aZeF+yg/veLxMUwpWSg+X7qZ7ScOH3UJt9 vL6w==
MIME-Version 1.0
X-Received by 10.52.52.137 with SMTP id t9mr2848369vdo.22.1386376790661; Fri, 06 Dec 2013 16:39:50 -0800 (PST)
In-Reply-To <52A269CB.9080704@gmail.com>
References <CAGGBd_o1TS02cosi+q9YeN5rnWJxe5mU7xtCTuTMZGO0ntF5TA@mail.gmail.com> <52A26763.3070803@gmail.com> <CAGGBd_rsP3rU6X30W_ocF8vNrPrLBrivT+nCv-1htgehmPZWrg@mail.gmail.com> <52A269CB.9080704@gmail.com>
Date Fri, 6 Dec 2013 19:39:50 -0500
Subject Re: One liners
From Joel Goldstick <joel.goldstick@gmail.com>
To Michael Torrie <torriem@gmail.com>
Content-Type multipart/alternative; boundary=089e0122f65e2211cf04ece70031
Cc Python 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 <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.3682.1386376799.18130.python-list@python.org> (permalink)
Lines 100
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1386376799 news.xs4all.nl 2944 [2001:888:2000:d::a6]:37991
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:61205

Show key headers only | View raw


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

On Fri, Dec 6, 2013 at 7:20 PM, Michael Torrie <torriem@gmail.com> wrote:

> On 12/06/2013 05:14 PM, Dan Stromberg wrote:
> > I'm thinking mostly of stackoverflow, but here's an example I ran into (a
> > lot of) on a job:
> >
> > somevar = some_complicated_thing(somevar) if
> > some_other_complicated_thing(somevar) else somevar
> >
> > Would it really be so bad to just use an if statement?  Why are we
> > assigning somevar to itself?  This sort of thing was strewn across 3 or 4
> > physical lines at a time.
>
> You're right that a conventional "if" block is not only more readable,
> but also faster and more efficient code.  Sorry you have to deal with
> code written like that!  That'd frustrate any sane programmer.  It might
> bother me enough to write code to reformat the program to convert that
> style to something sane!  There are times when the ternary (did I get
> that right?) operator is useful and clear.
> --
> https://mail.python.org/mailman/listinfo/python-list
>

While it seems to be a higher status in the team to write new code as
compared to fixing old code, so much can be learned by having to plough
through old code.  To learn others coding style, pick up new understanding,
and most importantly totally disabuse yourself of trying to be cute with
code.  Code is read by the machine and by the programmer.  The programmer
is the one who should be deferred to, imo.  You buy the machine, you rent
the programmer by the hour!

Aside from django urls, I am not sure I ever wrote regexes in python.  For
some reason they must seem awfully sexy to quite a few people.  Back to my
point above -- ever try to figure out a complicated regex written by
someone else?



-- 
Joel Goldstick
http://joelgoldstick.com

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


Thread

Re: One liners Joel Goldstick <joel.goldstick@gmail.com> - 2013-12-06 19:39 -0500
  Re: One liners Roy Smith <roy@panix.com> - 2013-12-06 19:56 -0500

csiph-web