On Fri, 17 Feb 2006, Phillip J. Eby wrote:
> > d = {} # or dict()
> > d.default_factory = list
>
> Why not a classmethod constructor:
>
> d = dict.with_factory(list)
>
> But I'd rather set the default and create the
> dictionary in one operation, since when reading it as two, you first think
> 'd is a dictionary', and then 'oh, but it has a default factory', as
> opposed to "d is a dict with a factory" in one thought.
Also, class method would mean less typing (esp if dictionary name
happens to be longer than a couple of characters ;-)
But I'd like to suggest a different name:
d = dict.with_default( list)
Ilya
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com