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/061535.html below:

[Python-Dev] defaultdict proposal round three

[Python-Dev] defaultdict proposal round three [Python-Dev] defaultdict proposal round threeDan Gass dan.gass at gmail.com
Tue Feb 21 00:08:07 CET 2006
On 2/20/06, Raymond Hettinger <raymond.hettinger at verizon.net> wrote:
>
>
> An alternative is to have two possible attributes:
>   d.default_factory = list
> or
>   d.default_value = 0
> with an exception being raised when both are defined (the test is done
> when the
> attribute is created, not when the lookup is performed).
>
>
Why not have the factory function take the key being looked up as an
argument?  Seems like there would be uses to customize the default based on
the key.  It also forces you to handle list factory functions and constant
factory functions (amongst others) to be handled the same way:

d.default_factory = lambda k : list()
d.default_factory = lambda k : 0

Dan Gass
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20060220/2f99b73a/attachment.htm 
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