|
|
Subscribe / Log in / New account

New operators for Python dicts?

New operators for Python dicts?

Posted Mar 5, 2015 14:30 UTC (Thu) by zyga (subscriber, #81533)
Parent article: New operators for Python dicts?

I'd like to clarify that __iadd__ and += are not that similar (when compared to __add__ and +).

Consider:

a = 1
a += 1

This calls int.__add__ as int.__iadd__ doesn't exist.

+= will always work if + is defined
__iadd__ may not be defined for certain types


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds