classification
Title: defaultdict doc makes incorrect reference to __missing__ method
Type: behavior Stage: committed/rejected
Components: Documentation Versions: Python 2.7
process
Status: pending Resolution: invalid
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, jjposner, r.david.murray, rhettinger
Priority: normal Keywords: patch

Created on 2010-08-06 14:55 by jjposner, last changed 2010-08-08 14:44 by jjposner.

Files
File name Uploaded Description Edit
defaultdict.patch jjposner, 2010-08-06 14:55 SVN diff of library/collections.rst review
Messages (4)
msg113105 - (view) Author: John Posner (jjposner) Date: 2010-08-06 14:55
The documentation for collections.defaultdict is confusing with respect to the __missing__ method. The fact is that a programmer using defaultdict does not need to know anything about __missing__.

The attached patch contains a rewrite of the entire section (but not the "defaultdict Examples" section, which is fine.
msg113140 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-08-06 22:02
I believe the description of __missing__ is there for those who want to subclass defaultdict, but I'll let Raymond confirm.
msg113269 - (view) Author: John Posner (jjposner) Date: 2010-08-08 14:40
I think it would be confusing to create of subclass of defaultdict, defining a __missing__ method in that subclass. The existence of the __missing__ method would cancel the main functionality of the defaultdict object: invoking the "default value factory" callable.

I think it would be better to encourage programmers to subclass dict directly, instead of subclassing defaultdict.
msg113270 - (view) Author: John Posner (jjposner) Date: 2010-08-08 14:43
On python-list, Wolfram Hinderer objected to the proposed patch's calling __missing__ a "special method".
History
Date User Action Args
2010-08-08 14:44:40jjposnersetstatus: open -> pending
2010-08-08 14:43:56jjposnersetmessages: + msg113270
2010-08-08 14:40:23jjposnersetstatus: pending -> open

messages: + msg113269
2010-08-06 22:02:13r.david.murraysetstatus: open -> pending

nosy: + rhettinger, r.david.murray
messages: + msg113140
resolution: invalid

type: behavior
stage: committed/rejected
2010-08-06 14:55:26jjposnercreate