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: 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: References: <52C59FF6.5000607@allsup.co> <52c62fa8$0$30001$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 3 Jan 2014 15:25:21 +1100 Subject: Re: Ifs and assignments From: Chris Angelico Cc: "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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Fri, Jan 3, 2014 at 3:14 PM, Roy Smith 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