![](https://secure.gravatar.com/avatar/7fc8d7e565378d3cc0816929c29b55de.jpg?s=120&d=mm&r=g)
Feb. 17, 2006
8:25 p.m.
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