"Magnus Lycka" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Statements and operators are really fundamental in Python. We > don't support n = 1.add(2), since we have the '+' operator.
Actually, since the 2.2 union of type and new-style classes, which gave attributes to all types .... >>> 1 .__add__(2) # note space after 1 3 >>> 1.__add__(2) # ambiguous, interpreter won't guess SyntaxError: invalid syntax >>> 1..__add__(2.) 3.0 I only see this as useful for making bound methods: >>> inc = 1 .__add__ >>> inc(2) 3 >>> dub = 2 .__mul__ >>> dub(2) 4 which is certainly nicer than the older method of writing a 'makeoper' function that returned a nested function with either a default param or a closure. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list