I haven't tested it, but did you encounter a problem defining __iadd__ in the class definition?<br>See:<br><a href="http://docs.python.org/reference/datamodel.html#object.__iadd__">http://docs.python.org/reference/datamodel.html#object.__iadd__</a><br>
<br>Cheers,<br><br clear="all">Ching-Yun "Xavier" Ho, Technical Artist<br><br>Contact Information<br>Mobile: (+61) 04 3335 4748<br>Skype ID: SpaXe85<br>Email: <a href="mailto:contact@xavierho.com">contact@xavierho.com</a><br>
Website: <a href="http://xavierho.com/">http://xavierho.com/</a><br>
<br><br><div class="gmail_quote">On Thu, Aug 27, 2009 at 8:48 AM, Robert Kern <span dir="ltr"><<a href="mailto:robert.kern@gmail.com">robert.kern@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On 2009-08-26 17:16 PM, RunThePun wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I'd like to build a database wrapper using DictMixin and allow items<br>
to be appended by my own code. The problem is += is always understood<br>
as setitem and getitem plainly.<br>
<br>
d = MyDict()<br>
d['a'] = 1<br>
<br>
# this is the problem code that's I'd like to override. It's always<br>
setitem('a', getitem('a') + 3)<br>
d['a'] += 3<br>
# i wanted to do something like my own 'appenditem' function which for<br>
example could be useful if getitem is an expensive operation which can<br>
be avoided.<br>
<br>
I hope that was clear enough of a request, it's really late at night<br>
here...<br>
</blockquote>
<br></div>
I'm sorry, this is just part of the syntax of Python. You cannot override it.<br><font color="#888888">
<br>
-- <br>
Robert Kern<br>
<br>
"I have come to believe that the whole world is an enigma, a harmless enigma<br>
 that is made terrible by our own mad attempt to interpret it as though it had<br>
 an underlying truth."<br>
  -- Umberto Eco</font><div><div></div><div class="h5"><br>
<br>
-- <br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br>