Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #2719

Re: a better way to invert a list?

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 <ian.g.kelly@gmail.com>
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 <ian.g.kelly@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.84.1302120558.9059.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Wed, Apr 6, 2011 at 1:51 PM, Paul Rubin <no.email@nospam.invalid> wrote:
>    In Haskell or ML, you can use patterns that contain wild
>    cards that play a role in the pattern-matching but don't establish any
>    binding. Can that be done in Python?
>
> Not as much.  You could say something like
>
>         sorted(enumerate(p), key=lambda(_,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.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

a better way to invert a list? scattered <tooscattered@gmail.com> - 2011-04-05 14:17 -0700
  Re: a better way to invert a list? Ian Kelly <ian.g.kelly@gmail.com> - 2011-04-05 15:46 -0600
    Re: a better way to invert a list? scattered <tooscattered@gmail.com> - 2011-04-05 16:24 -0700
      Re: a better way to invert a list? Glazner <yoavglazner@gmail.com> - 2011-04-06 01:48 -0700
        Re: a better way to invert a list? scattered <tooscattered@gmail.com> - 2011-04-06 02:48 -0700
        Re: a better way to invert a list? Peter Otten <__peter__@web.de> - 2011-04-06 11:58 +0200
    Re: a better way to invert a list? Raymond Hettinger <python@rcn.com> - 2011-04-05 17:07 -0700
  Re: a better way to invert a list? Paul Rubin <no.email@nospam.invalid> - 2011-04-06 12:51 -0700
    Re: a better way to invert a list? Ian Kelly <ian.g.kelly@gmail.com> - 2011-04-06 14:08 -0600

csiph-web