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

Josiah Carlson jcarlson at uci.edu
Sun Feb 19 04:50:07 CET 2006


Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

Bengt Richter wrote:

> My guess is that realistically defaultfactory will be used > to make clean code for filling a dict, and then turning the factory > off if it's to be passed into unknown contexts. This suggests that maybe the autodict behaviour shouldn't be part of the dict itself, but provided by a wrapper around the dict. The you can fill the dict through the wrapper, and still have a normal dict underneath to use for other purposes.

I prefer this to changing dictionaries directly. The actual wrapper could sit in the collections module, ready for subclassing/replacement of the on_missing method.



More information about the Python-Dev mailing list