a = b = 1 just syntactic sugar?
Ed Avis
ed at membled.com
Sun Jun 8 08:24:07 EDT 2003
mis6 at pitt.edu (Michele Simionato) writes:
>>A couple more anomalous cases could be cleaned up by adding dict.set
>>as a counterpart of dict.setdefault
>
>Am I mistaken or you want dict.__setitem__ ?
Yes, but ideally without the four underscores which seem to convey
'internal stuff, you're not really meant to call this'. Perhaps I am
just too squeamish and good Python programmers have no objection to
writing code full of __x__(). I know I've seen some code by Guido
which looks like that.
I would however fix the documentation at
<http://www.python.org/doc/current/lib/typesmapping.html> so that it
mentions __setitem__ and and other built-in methods. At the moment it
lists a[k] = v, which AFAIK is syntactic sugar for the expression
a.__setitem__(k, v), but it does not list the __setitem__ method
itself.
--
Ed Avis <ed at membled.com>
More information about the Python-list
mailing list