[Python-Dev] Counter proposal: multidict (was: Proposal: defaultdict)

Jack Diederich jack at performancedrivers.com
Fri Feb 17 21:25:14 CET 2006


On Fri, Feb 17, 2006 at 03:03:06PM -0500, Fred L. Drake, Jr. wrote:
> On Friday 17 February 2006 14:51, Ian Bicking wrote:
> > and in the process breaking an important 
> > quality of good Python code, that attribute and getitem access not have
> > noticeable side effects.
>> I'm not sure that's quite as well-defined or agreed upon as you do.
 
Without the __getitem__ side effect default objects that don't support any
operators would have problems.
 d[key] += val
works fine when the default is a list or int but fails for dicts and presumably
many user defined objects. By assigning the default value in __getitem__ the
returned value can be manipulated via its methods.
-Jack


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /