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


Groups > comp.lang.python > #63030

Re: Ifs and assignments

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'else:': 0.03; 'wrapper': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'jan': 0.12; 'cleaner': 0.16; 'dig': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'handler,': 0.16; 'perfect.': 0.16; 'roy': 0.16; 'true:': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'certainly': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'fri,': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'var': 0.36; 'yield': 0.36; 'turn': 0.37; 'generic': 0.38; 'pm,': 0.38; 'itself': 0.39; 'even': 0.60; 'break': 0.61; 'kind': 0.63; 'smith': 0.68; 'thoroughly': 0.91; 'to:none': 0.92
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:cc :content-type; bh=sfmM7BvOqKZl8Q92SY4+wAndqAv5mhYBPmXyd/jPXts=; b=JT2KMdgu6jPOZh/X5Je6K7sPzM/poGfNXAwWAjl9cZkQ/xgrkTitwIvUUg8l4JHycn khxXV4VrIGUSES1wbBBknDSue6aiyB326tlvx1/4gQusZy/zjUIAIjR+z5ofcytiu2oJ SfdYR0KbKJZGEJHd1EUStpQ7xOzYbSLtsQIuKf5VOU4i86/Bc7GLr54aa+zDP0r8pEix vHOTco9IHasPKmlsWR7lNQVWewFWBDjhGZFYaaiwZZCkhdjDl3KqVlX8Ge8uNOV2U6R9 OTULlD1EmXbWNNosMzjDc21io8jxOeIDKJrO4XIFCGOa42nDZQq4WFhPZsMTzAztPEjh mfCA==
MIME-Version 1.0
X-Received by 10.66.67.3 with SMTP id j3mr75707307pat.142.1388723121581; Thu, 02 Jan 2014 20:25:21 -0800 (PST)
In-Reply-To <roy-9D0E6B.23144702012014@news.panix.com>
References <52C59FF6.5000607@allsup.co> <mailman.4816.1388709915.18130.python-list@python.org> <52c62fa8$0$30001$c3e8da3$5496439d@news.astraweb.com> <mailman.4823.1388720985.18130.python-list@python.org> <roy-9D0E6B.23144702012014@news.panix.com>
Date Fri, 3 Jan 2014 15:25:21 +1100
Subject Re: Ifs and assignments
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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.4828.1388723131.18130.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1388723131 news.xs4all.nl 2874 [2001:888:2000:d::a6]:40505
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63030

Show key headers only | View raw


On Fri, Jan 3, 2014 at 3:14 PM, Roy Smith <roy@panix.com> wrote:
> Or turn it into a generator:
> That certainly makes your mainline code cleaner...

Cleaner perhaps, but not clearer. Instead of seeing the original
function (say, a database retrieve-next call), you see a wrapper and
have to go dig to find out what it's actually doing. Unless it's some
kind of generic handler, like:

def funcinator(func,*args):
   while True:
      var = func(*args)
      if var:
         yield var
      else:
         break

while funcinator(cur.getnext):
    ....

But even that would be problematic until it got so thoroughly
understood that it's like enumerate() - which is itself still not
perfect.

ChrisA

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


Thread

Re: Ifs and assignments Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-02 19:45 -0500
  Re: Ifs and assignments Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-03 14:33 +1100
    Re: Ifs and assignments Chris Angelico <rosuav@gmail.com> - 2014-01-03 14:49 +1100
      Re: Ifs and assignments Roy Smith <roy@panix.com> - 2014-01-02 23:14 -0500
        Re: Ifs and assignments Chris Angelico <rosuav@gmail.com> - 2014-01-03 15:25 +1100
        Re: Ifs and assignments Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-03 04:29 +0000
      Re: Ifs and assignments Duncan Booth <duncan.booth@invalid.invalid> - 2014-01-03 15:46 +0000
    Re: Ifs and assignments Chris Angelico <rosuav@gmail.com> - 2014-01-03 14:55 +1100
      Re: Ifs and assignments Roy Smith <roy@panix.com> - 2014-01-02 23:00 -0500
        Re: Ifs and assignments Chris Angelico <rosuav@gmail.com> - 2014-01-03 15:08 +1100

csiph-web