On Thu, Jun 25, 2020 at 7:55 PM Christopher Barker <python...@gmail.com>
wrote:

> On Thu, Jun 25, 2020 at 9:02 AM Steele Farnsworth <swfarnswo...@gmail.com>
> wrote:
> indeed -- and that is pretty darn baked in to Python, so I don't think
> it's going to change.
>
>
Except this convention doesn't hold for dict.setvalue (which I did
misspell, sorry), or for dict.pop. Both these methods fundamentally mutate
the collection, but they also return a value (which could be retrieved by a
non-mutating method), that somewhat pertains to the operation performed.


> Note: I"n not sure your example with setdefault is correct:
>

Fair enough, I misspelled setdefault and messed up the example, what I
meant was:
seen = {}
for k, v in iterable_of_tuples:
  if seen.setdefault(k,v) is not v:
    ... # duplicate key
  else:
    ... # new key
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/PSQRU7QZHFFTFA45DQJKQF4RLFIHSGMF/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to