Behaviour of pop() for dictionaries

Chris Angelico rosuav at gmail.com
Mon Jun 14 15:43:37 EDT 2021


On Tue, Jun 15, 2021 at 5:41 AM BlindAnagram <blindanagram at nowhere.org> wrote:
> However, d.pop(key, [default]) returns the value (or the default) and
> consistency with other pops (a good thing in my view) would suggest that
> d.pop() could return a random value, which would serve my purpose when
> there is only one element.
>

Is this actually important or are you just looking for a meaningless
"inconsistency"? Dictionaries are fundamentally different from lists.
Is it really that hard to use popitem?

ChrisA


More information about the Python-list mailing list