Is there any good reason why no set method in Python dict?

2 pointsposted a year ago
by somesun

Item id: 41834008

3 Comments

user

a year ago

[deleted]

user

a year ago

[deleted]

zahlman

a year ago

> ''' if exists is False , will not overwrite current key if it's alreay there '''

...That's what `setdefault` does. It just also returns the value, which you're free to ignore. (The other version is what ordinary key assignment does.)

Also, that's really not a clear name for the parameter at all.