[docs] [issue10533] Need example of using __missing__

Éric Araujo report at bugs.python.org
Thu Nov 25 21:32:46 CET 2010


Éric Araujo <merwok at 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: +docs at 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 <report at bugs.python.org>
<http://bugs.python.org/issue10533>
_______________________________________


More information about the docs mailing list