Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #2719
| References | <2215eefd-3677-4459-8656-aa04978f6f3f@g7g2000pro.googlegroups.com> <7xwrj7kvjv.fsf@ruckus.brouhaha.com> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2011-04-06 14:08 -0600 |
| Subject | Re: a better way to invert a list? |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.84.1302120558.9059.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Find similar | Unroll 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