Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: Mel Newsgroups: comp.lang.python Subject: Re: Feature suggestion -- return if true Followup-To: comp.lang.python Date: Tue, 12 Apr 2011 11:12:09 -0400 Organization: Aioe.org NNTP Server Lines: 31 Message-ID: References: <8abff237-5ccd-4eb6-85c8-cdc9e87520b7@bl1g2000vbb.googlegroups.com> <7xoc4cymz7.fsf@ruckus.brouhaha.com> Reply-To: mwilson@the-wire.com NNTP-Posting-Host: VohAM+2kxuRWxLTzbglp8Q.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@aioe.org User-Agent: KNode/4.4.8 X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3055 Paul Rubin wrote: > zildjohn01 writes: >> _temp = expr >> if _temp: return _temp > > I'm trying to figure out a context where you'd even want that, and I'm > thinking that maybe it's some version of a repeat-until loop? Python > doesn't have repeat-until and it's been proposed a few times. I can imagine return? tree_node.left return? tree_node.right although my real code would probably be more like if tree_node.left is not None: return "left", tree_node.left if tree_node.right is not None: return "right", tree_node.right where adding the "left" and "right" markers makes the return? feature impossible to use. The proposed feature reminds me of the `zod` function (was that the actual name?) that returned 0 rather than bringing on a ZeroDivideError. It would cement a strange corner-case into the language. Mel.