Suppose I have a collection events
which contains tuples of length two that store some arbitrary information, for example a day and an event.
In Python 2 I can write the very readable
sortkey = lambda (day, event): some_function(day)
events_sorted = sorted(events, key=sortkey)
In Python 3, the first line will raise a SyntaxError
because tuple parameter unpacking has been removed. I cannot use a two argument lambda-function as the key, so I have to resort to the far less readable
sortkey = lambda day_and_event: some_function(day_and_event[0])
Is there a better way?