a better way to invert a list?
ian.g.kelly at gmail.com
Wed Apr 6 16:08:45 EDT 2011
On Wed, Apr 6, 2011 at 1:51 PM, Paul Rubin <no.email at 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
More information about the Python-list