Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!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.028 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'arguments': 0.09; 'definition,': 0.09; 'cc:addr:python-list': 0.11; 'jan': 0.12; 'be:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'syntaxerror:': 0.16; 'tuple': 0.16; 'unpacking': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'creating': 0.23; '"you': 0.24; '31,': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'am,': 0.29; 'points': 0.29; 'message- id:@mail.gmail.com': 0.30; 'that.': 0.31; 'fri,': 0.33; 'totally': 0.33; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'anything': 0.39; 'skip:p 20': 0.39; 'ian': 0.60; 'course': 0.61; "you're": 0.61; 'skip:n 10': 0.64; 'score': 0.74; 'better!': 0.91; 'subject:True': 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=axusk/EFdoIhIFdcd16DexxCw4pEM/gLtSCD+1C4OKQ=; b=DuyYt4mrg/tTzAFlHDL3FnE2iQSRQtSFdHsUYpMZRZbFOMML0zn9WDE7ux06cg27PX 3na3B1VExQLWMnCgYD2AngR/yg5Cptg1T4j7JB6u+SK+EXuC3vJsrvrzj6tpzcw/+TBp yyT8G0l+KeyYWw4812rR40adNrMDlM2RI7yy4RQrO/eCd3l+A/Klkdn82eMvAuJSNSHd jAm/dpI9bfm70mduY4Qj1JvGWtIDY89jNIYYUSoBj8lkuzoN/OkOgNHPFtpVgmyWcK8o lp7arl1Ry2A+9UBXD6vz+kD4T+iZ7IKpZ+TEsQhjLkkATCDmxUT+EJUDFDjLhrVYtsfU L7KA== MIME-Version: 1.0 X-Received: by 10.66.102.39 with SMTP id fl7mr16380442pab.43.1391114329390; Thu, 30 Jan 2014 12:38:49 -0800 (PST) In-Reply-To: References: <99b0aa22-5fb3-460a-a080-dacb1c0f2fda@googlegroups.com> Date: Fri, 31 Jan 2014 07:38:49 +1100 Subject: Re: 1 > 0 == True -> False From: Chris Angelico Cc: Python 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391114334 news.xs4all.nl 2861 [2001:888:2000:d::a6]:60812 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65049 On Fri, Jan 31, 2014 at 7:28 AM, Ian Kelly wrote: > Of course if you're at all concerned about i18n then the proper way to > do it would be: > > ngettext("You have scored %d point", "You have scored %d points", score) % score Ugh, so much duplication! We can totally do better than that. ngettext(*(lambda x,s: (x,x+'s',s))("You have scored %d point",score)) Much better! Incidentally, in creating the above abomination, I found that I can't do this: >>> print(*(lambda x: (x,x+'s'))("You have scored %d point"),score) SyntaxError: only named arguments may follow *expression But I can do this: >>> print(score,*(lambda x: (x,x+'s'))("You have scored %d point")) 1 You have scored %d point You have scored %d points Why is tuple unpacking limited to the last argument? Is it just for the parallel with the function definition, where anything following it is keyword-only? ChrisA