Éric Araujo <mer...@netwok.org> added the comment:

> 4. I cannot come up with another typical integer value that would be
> useful, then again I've used "", [] and set() numerous times.
You can get '' with str as default factory and [] with list.

I think we agree on reclassifying this as a doc problem.  Proposal:

1) Add a small example in stdtypes.rst:dict section.

2) Add examples of giving dict or int to collections.defaultdict to get {} or 0 
as default value.

3) Find a way to link to that example from the index.  It is not currently 
indexed because there is no dict.__missing__ method, hence no method markup 
that would trigger indexing.

4) Cross-link collections.rst:defaultdict, collections.rst:Counter and 
stdtypes.rst:__missing__ example.

----------
components: +Documentation -Library (Lib)
nosy: +d...@python
stage:  -> needs patch
title: defaultdict constructor with a concrete value -> Need example of using 
__missing__
versions: +Python 2.7, Python 3.1

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue10533>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to