"sturlamolden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | | Python allows the binding behaviour to be defined for descriptors, | using the __set__ and __get__ methods. I think it would be a major | advantage if this could be generalized to any object, by allowing the | assignment operator (=) to be overloaded.
Conceptually, assignment is *not* an operator. Binary operators take two values (of the same type) and produce a third (usually of either the input type or a boolean) that usually depends on both inputs. Assignment does nothing of the sort. In Python, the equal sign is *not* an operator: it is a grammatical symbol. One use of the operator fiction in C is to enable simple chained assignment: a=b=2. Python does this directly without the fiction. C's store-and-test usage can be implemented in Python with a 'purse' class. | One particular use for this would be to implement "lazy evaluation". Since (in Python, at least) operands are evaluated *before* the operator/function is called, I do not see how. | Should there be a PEP to overload the assignment operator? You mean a PEP to make assignment an (pseudo)operation and hence overloadable (as all operators are). That has been proposed and rejected before, more than once, but I don't have a reference handy. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list