Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'escape': 0.04; 'wed,': 0.04; 'implicit': 0.07; 'patterns': 0.07; 'python?': 0.07; 'python': 0.07; '(it': 0.09; 'tuple': 0.09; 'pm,': 0.11; 'wrote:': 0.14; 'unpacking': 0.16; '\xa0in': 0.16; '\xa0you': 0.16; 'subject:list': 0.22; 'header:In-Reply-To:1': 0.22; 'statement': 0.26; 'message-id:@mail.gmail.com': 0.28; "doesn't": 0.28; 'received:209.85.160': 0.28; 'subject:?': 0.29; 'meaning': 0.31; 'paul': 0.32; 'to:addr:python-list': 0.32; 'done': 0.32; 'received:209.85.160.46': 0.33; 'received:mail- pw0-f46.google.com': 0.33; 'assignment': 0.35; 'explicit': 0.35; 'symbol': 0.35; 'received:209.85': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'but': 0.38; 'establish': 0.38; 'though': 0.38; 'role': 0.39; 'much.': 0.39; 'to:addr:python.org': 0.39; 'could': 0.39; 'received:209': 0.39; 'header:Received:5': 0.40; 'give': 0.61; '2011': 0.62; 'play': 0.64; 'subject:better': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; bh=GVvNiorO9pKOAH4uL3pWo2wXDO3FxhxK5liwYb9usCQ=; b=cKF777RrOJgjZc9eW5AT5N9/Q8Zl5SYKgnrBmn3cH5LKA3cxfACJkVxwCP7My/CI12 QS7N6tvIISk0AldI+fi5Bb7jsdYedhH33ecmY1GQjWGwR3EwXQVMeqiUS56iPZQmZBHW Y/ldpeVbhPvEZB8L/HRW0A1uYmkLN4YvXTuLU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=DHX2jOhUK1LRshgzf94WqDbT7aPwUrtiscRBXnA3wY5ZcJpIMLjmXSDqsIlM+pKrlo wtaHRCH0YGODMNM+Byi8mINdDXgm5VmASrmxSHfXOZ/2YUJa4zf5JACYISrvffAL3/yu uFnoQinSz0/qDyb8iqoBek710vVpPrDW4ZOVw= MIME-Version: 1.0 In-Reply-To: <7xwrj7kvjv.fsf@ruckus.brouhaha.com> References: <2215eefd-3677-4459-8656-aa04978f6f3f@g7g2000pro.googlegroups.com> <7xwrj7kvjv.fsf@ruckus.brouhaha.com> From: Ian Kelly Date: Wed, 6 Apr 2011 14:08:45 -0600 Subject: Re: a better way to invert a list? 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: 16 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1302120558 news.xs4all.nl 81475 [::ffff:82.94.164.166]:59638 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:2719 On Wed, Apr 6, 2011 at 1:51 PM, Paul Rubin wrote: > =A0 =A0In Haskell or ML, you can use patterns that contain wild > =A0 =A0cards that play a role in the pattern-matching but don't establish= any > =A0 =A0binding. Can that be done in Python? > > Not as much. =A0You could say something like > > =A0 =A0 =A0 =A0 sorted(enumerate(p), key=3Dlambda(_,j): j) > > which gets the meaning across (it binds the symbol "_" though this > doesn't escape the lambda). That will just give you a SyntaxError. Implicit tuple unpacking was removed in Python 3. It has to be done with an explicit assignment statement now.