Comment by sischoel
1 day ago
Or use itemgetter:
>>> from operator import itemgetter
>>> dct = {'greeting': 'hello', 'thing': 'world', 'farewell': 'bye'}
>>> thing, greeting = itemgetter("thing", "greeting")(dct)
>>> thing
'world'
>>> greeting
'hello'
Ohhh, nice. Also, attrgetter (which also supports dotted notation to get nested attrs! Sadly, no dotted notation for itemgetter.)
https://docs.python.org/3/library/operator.html#operator.att...
There are so many things like this one in the standard library that it kinda pisses me off when I discover a new one.