operator overloading on built-ins

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Fri Nov 9 08:33:07 CET 2007


On Thu, 08 Nov 2007 22:53:16 -0800, r.grimm wrote:

>>>> (1).__cmp__(10)
> -1

As the dot is an operator like ``+`` or ``/`` you can also add spaces to
avoid the ambiguity:

In [493]: 1 . __cmp__(10)
Out[493]: -1

In [494]: 1 .__cmp__(10)
Out[494]: -1

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list