Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.032 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'dictionary': 0.07; 'def': 0.13; 'am,': 0.14; 'wrote:': 0.14; 'expression,': 0.16; 'hmm.': 0.16; 'tue,': 0.20; 'header:In-Reply-To:1': 0.22; 'received:209.85.214.174': 0.23; 'received:mail- iw0-f174.google.com': 0.23; 'version': 0.25; 'subject: -- ': 0.25; 'chris': 0.27; 'message-id:@mail.gmail.com': 0.28; 'skip:( 20': 0.31; 'to:addr:python-list': 0.32; 'assignment': 0.35; 'getting': 0.36; 'else': 0.37; 'received:209.85': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'but': 0.38; 'received:209.85.214': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.39; "it's": 0.40; 'header:Received:5': 0.40; '2011': 0.62; 'legal': 0.64 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=DRYioHeBHdX9iXmHzEIhpeSRtBSqbLBUZB8KRlFdRj4=; b=f5Ug1P2gSK+Lt8PZPjO/LQCzacCacBI3HG3Zh2xBRDASa7JB7bipGuH3PIYiNWd5l/ yYvuSmQaeLDxL2zqSxOGdHaR2qNR2QdZTBNsBadmTGv1V6NjLBHMCj0UM33jNBSOuV3g hAWSAv3t+elrIWHYGG/512+4qvkmJGpO5ksEo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=fvdLkcN/IZ4hGwDCPtoKVLAf9tV22nwv16fMI/hpL5fDeMSl2XH6KAi41ZBU83+PYb uS1B8Itr8FB08tqINAp62J4bOTd5quRFeKry3GiH00o91viiHpSemoM1g2G8KMWohgjL ej24WGdwaxf+bKf/URctaQhppq+fYGncMs8kg= MIME-Version: 1.0 In-Reply-To: References: <8abff237-5ccd-4eb6-85c8-cdc9e87520b7@bl1g2000vbb.googlegroups.com> Date: Tue, 12 Apr 2011 10:51:06 +1000 Subject: Re: Feature suggestion -- return if true From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 12 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1302569468 news.xs4all.nl 81475 [::ffff:82.94.164.166]:40317 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3010 On Tue, Apr 12, 2011 at 10:46 AM, Chris Angelico wrote: > def fac(n): > =A0 =A0return cache[n] or (cache[n]=3D1 if n<=3D1 else fac(n-1)*n) Hmm. The function-call version of dictionary assignment IS legal in an expression, but it's getting stupid... def fac(n): return cache.get(n) or (cache.__setitem__(n,1 if n<=3D1 else fac(n-1)*n) or cache[n]) Chris Angelico