operator overloading on built-ins

r.grimm at science-computing.de r.grimm at science-computing.de
Fri Nov 9 01:53:16 EST 2007


Hallo,
could you explaint me the difference between the two following
statements.


Python 2.5 (r25:51908, Oct  7 2006, 23:45:05)
[GCC 3.3.5 20050117 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> (1).__cmp__(10)
-1
>>> 1.__cmp__(10)
  File "<stdin>", line 1
    1.__cmp__(10)
            ^
SyntaxError: invalid syntax

The first works as expect, but the second.

Regards Rainer




More information about the Python-list mailing list