recursion in __cmp__
John Doe
atterdan at yahoo.com
Fri Nov 5 04:46:20 EST 2004
Really Victor,
no one comments on old versions. Try it on 2.3.
Dan
On Fri, 05 Nov 2004 00:45:28 -0800, Victor Safronovich wrote:
> please comment this
> Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on win32
>>>> class A:
> def __cmp__(self, other):
> print '%s|%s' %(`self`, `other`)
> return cmp(self, other)
>
>>>> a = A()
>>>> cmp(a,A())
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> <__main__.A instance at 0x00989838>|<__main__.A instance at 0x0097D120>
> 0
>>>> cmp(a,5)
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> <__main__.A instance at 0x00989838>|5
> 0
More information about the Python-list
mailing list