Csaba Hoch wrote:
if I write the following:
>>> 1+1
2
it seems to be exactly equivalent to this:
>>> (1).__add__(1)
2
However, if I write invalid code and try to add a list to an int, the
errors will be different: ....
As has been explained, binary operators are trickier than the above
seems to show. Here is how to get the full behavior:
>>> import operator
>>> operator.add(1,[])
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
operator.add(1,[])
TypeError: unsupported operand type(s) for +: 'int' and 'list'
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list