On Mon, May 27, 2019 at 6:05 AM Yanghao Hua <yanghao...@gmail.com> wrote: > Doesn't matter how it ends up, I > urge the python community do give it a second thought. (Don't you guys > think it is odd that Python can overrides almost every operation but > not for assignment ... is assignment really worthy being a special > case?!)
Yes. It IS a special case, because assignment is not handled by the object being assigned to. When you assign to an attribute or subscript of an object, the *parent* object determines how the assignment is done, not the one being replaced. Look at languages where the being-replaced object gets to redefine assignment (C++ and PHP come to mind, and there may be others). MANY MANY parts of your code become harder to comprehend. It's not the only thing special enough to be non-overridable. In Python, you have several fundamentals that are absolutely guaranteed: a = b a is b b if a else c a or b # a and b There is no way that the values of a, b, or c can change the meanings of these expressions. (The truthiness of 'a' will define which of two options is chosen, but you cannot redefine the operator itself.) This is a Good Thing. ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/