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


Groups > comp.lang.python > #61201

Re: One liners

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <torriem+gmail@torriefamily.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'operator': 0.03; 'assigning': 0.09; 'dan': 0.09; 'reformat': 0.09; 'cc:addr:python- list': 0.11; 'mostly': 0.14; '"if"': 0.16; 'cc:name:python list': 0.16; 'clear.': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'of)': 0.16; 'sane': 0.16; 'ternary': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'written': 0.21; 'example': 0.22; 'cc:addr:python.org': 0.22; 'header:User- Agent:1': 0.23; 'cc:2**0': 0.24; 'sort': 0.25; 'header:In-Reply- To:1': 0.27; "i'm": 0.30; 'code': 0.31; 'lines': 0.31; 'style': 0.33; 'skip:s 30': 0.35; 'something': 0.35; 'convert': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'that!': 0.36; 'useful': 0.36; 'message-id:@gmail.com': 0.38; 'pm,': 0.38; 'bad': 0.39; 'enough': 0.39; 'received:org': 0.40; "you're": 0.61; 'times': 0.62; 'more': 0.64; 'physical': 0.72; 'subject:One': 0.74; 'itself?': 0.84; 'to:none': 0.92
X-Virus-Scanned amavisd-new at torriefamily.org
Date Fri, 06 Dec 2013 17:20:27 -0700
From Michael Torrie <torriem@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130105 Thunderbird/10.0.12
MIME-Version 1.0
CC Python List <python-list@python.org>
Subject Re: One liners
References <CAGGBd_o1TS02cosi+q9YeN5rnWJxe5mU7xtCTuTMZGO0ntF5TA@mail.gmail.com> <52A26763.3070803@gmail.com> <CAGGBd_rsP3rU6X30W_ocF8vNrPrLBrivT+nCv-1htgehmPZWrg@mail.gmail.com>
In-Reply-To <CAGGBd_rsP3rU6X30W_ocF8vNrPrLBrivT+nCv-1htgehmPZWrg@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
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.3678.1386375653.18130.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1386375653 news.xs4all.nl 2841 [2001:888:2000:d::a6]:53792
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:61201

Show key headers only | View raw


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.

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


Thread

Re: One liners Michael Torrie <torriem@gmail.com> - 2013-12-06 17:20 -0700
  Re: One liners Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-07 02:28 +0000
    Re: One liners Chris Angelico <rosuav@gmail.com> - 2013-12-07 13:40 +1100
    Re: One liners Roy Smith <roy@panix.com> - 2013-12-06 22:27 -0500
      Re: One liners Chris Angelico <rosuav@gmail.com> - 2013-12-07 15:06 +1100
      Re: One liners Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-07 11:27 +0000
        Re: One liners Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-12-07 14:41 +0200
          Re: One liners Rotwang <sg552@hotmail.co.uk> - 2013-12-07 16:13 +0000
            Re: One liners Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-07 16:25 +0000
              Re: One liners Rotwang <sg552@hotmail.co.uk> - 2013-12-08 02:23 +0000
            Re: One liners Michael Torrie <torriem@gmail.com> - 2013-12-07 09:26 -0700
            Re: One liners Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-12-07 19:49 +0200
            Re: One liners Terry Reedy <tjreedy@udel.edu> - 2013-12-07 16:02 -0500
      Re: One liners Michael Torrie <torriem@gmail.com> - 2013-12-07 09:56 -0700
        Re: One liners rusi <rustompmody@gmail.com> - 2013-12-07 09:10 -0800
      Re: One liners Michael Torrie <torriem@gmail.com> - 2013-12-07 10:02 -0700

csiph-web