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 _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com