A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-February/061701.html below:

[Python-Dev] defaultdict and on_missing()

[Python-Dev] defaultdict and on_missing() [Python-Dev] defaultdict and on_missing()Fredrik Lundh fredrik at pythonware.com
Wed Feb 22 12:54:28 CET 2006
Raymond Hettinger wrote:

> Aside:  Why on_missing() is an oddball among dict methods.  When
> teaching dicts to beginner, all the methods are easily explainable ex-
> cept this one.  You don't call this method directly, you only use it
> when subclassing, you have to override it to do anything useful, it
> hooks KeyError but only when raised by __getitem__ and not
> other methods, etc.

agreed.

> My recommendation:  Dump the on_missing() hook.  That leaves
> the dict API unmolested and allows a more straight-forward im-
> plementation/explanation of collections.default_dict or whatever
> it ends-up being named.  The result is delightfully simple and easy
> to understand/explain.

agreed.

a separate type in collections, a template object (or factory) passed to
the constructor, and implementation inheritance, is more than good en-
ough.  and if I recall correctly, pretty much what Guido first proposed.
I trust his intuition a lot more than I trust the design-by-committee-with-
out-use-cases process.

</F> 



More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4