[Python-ideas] dict.setdefault_call(), or API variations thereupon

Alex Shafer ashafer01 at gmail.com
Thu Nov 1 22:58:28 EDT 2018


So it actually sounds like having a dict method for performing write
operations with a factory function would be a semantic improvement.

On Thu, Nov 1, 2018 at 8:50 PM Guido van Rossum <guido at python.org> wrote:

> On Thu, Nov 1, 2018 at 7:23 PM Robert Vanden Eynde <robertve92 at gmail.com>
> wrote:
>
>> The two are less connected than you seem to think.
>>>
>>
>> Really ? What's the use mainstream use cases for setdefault ?
>> I was often in the case of Alex.
>>
>
> Well, defaultdict configures a default when an instance is created, while
> setdefault() is used when inserting a value.
>
> A major issue IMO with defaultdict is that if you try to *read* a
> non-existing key it will be inserted.
>
> --
> --Guido van Rossum (python.org/~guido)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20181101/6f30cb45/attachment.html>


More information about the Python-ideas mailing list