>
> [Bar Harel]
> > As for get(). Current implementation of UserDict returns the default
> value
> > for get() if __missing__() raises KeyError.  Which sounds reasonable to
> me.
> > After all, you would logically expect __missing__ to be called for get()
> > as you tried to get a non-existing value.
>
>
> [Ethan Furman]
> I disagree.  My understanding of the purpose behind get() is to get a value
> or return the default specified in the get() call, not to create a new key
> (which the default __missing__ does).
>

There is no default __missing__. That's what the __missing__ at defaultdict
does.

Like I said before: The fact __missing__ is not called for missing values
is a bit funny in my opinion, but it doesn't actually matter cause we can't
do anything about it without breaking lots of stuff (e.g. making
defaultdict.get worthless).
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/3HPG4NPXSVOB3Q5HE7TQE37JG6TUFLMC/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to