Gabriel Genellina wrote:
The operator "+" does more than blindy calling left.__add__(right). In
this case, as int + list returns NotImplemented, it reverses the
operands and tries right.__radd__(left), and only then it gives up and
raises TypeError.
The actual rules are a bit more complex, involving type conversion too;
see http://docs.python.org/reference/datamodel.html#emulating-numeric-types
Thanks for both of you, it's much clearer now.
Just a correction: according to the doc, NotImplemented is not an
error, but a returned value.
Csaba
--
http://mail.python.org/mailman/listinfo/python-list