Python dot-equals (syntax proposal)

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sat May 1 22:24:16 EDT 2010


On Sat, 01 May 2010 19:03:04 -0700, Chris Rebert wrote:

> On Sat, May 1, 2010 at 6:32 PM, Steven D'Aprano
> <steve at remove-this-cybersource.com.au> wrote:
>> On Sat, 01 May 2010 07:13:42 -0500, Tim Chase wrote:
>>> This doesn't preclude you from implementing a self-mutating += style
>>> __add__ method and returning "self", but it's usually a bad idea
>>
>> Obviously the Python dev team don't agree with that :)
>>
>> Just to prove that += for lists is not an accident:
[...]
> In both cases, __iOP__ operator methods are being used, not vanilla
> __OP__ methods, so neither of your examples are relevant to Mr. Chase's
> point.


I'm sorry, I read Tim's reference to __add__ (instead of __iadd__) as a 
typo. Having __add__ mutate self would be a strange thing to do.



-- 
Steven



More information about the Python-list mailing list