[Python-ideas] Unpacking a dict
Terry Reedy
tjreedy at udel.edu
Thu May 26 01:48:05 EDT 2016
On 5/26/2016 1:09 AM, Michael Selik wrote:
> I agree that comprehensions plus tuple unpacking handle many possible
> use cases for dict unpacking.
There is another dict method that has been ignored in this discussion.
>>> mapping = {'a': 1, 'b': 2, 'c': 3}
>>> x = mapping.pop('a')
>>> mapping
{'c': 3, 'b': 2}
We have both subscripting and popping to handle getting a value and
either leaving or removing the pair.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list