Hrvoje Niksic <[EMAIL PROTECTED]> wrote:

> [EMAIL PROTECTED] writes:
> 
>> Right, the paragraph is actually pretty clear after a second
>> reading.  I find it surprising nonetheless, as it's easy to forget
>> to return a result when you're implementing a method that does an
>> in-place operation, like __iadd__:
> 
> I've recently been bitten by that, and I don't understand the
> reasoning behind __iadd__'s design.  I mean, what is the point of an
> *in-place* add operation (and others) if it doesn't always work
> in-place?
> 
A very common use case is using it to increment a number:

   x += 1

If += always had to work inplace then this would throw an exception: an 
inplace addition would be meaningless for Python numbers.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to