[Python-Dev] Proposal: defaultdict (original) (raw)

Guido van Rossum guido at python.org
Sat Feb 18 01:20:46 CET 2006


On 2/17/06, "Martin v. Löwis" <martin at v.loewis.de> wrote:

That's why I think haskey and in should return True for any key. This leaves keys(), items(), and values(). From a pure point of view, they should return infinite sets. Practicality beats purity, so yes, d[k] could be considered a modifying operation.

I think practicality beats purity even for has_key/in; IMO these operations are more useful when they match keys() instead of always returning True. But someone should start writing some code to play with this.

I have a working patch (including a hack for PyDict_GetItem()): python.org/sf/1433928

So there's no excuse to be practical now.

-- --Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list