[Python-bugs-list] [ python-Bugs-442758 ] 2.2a1: New style classes and __cmp__
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 19 Jul 2001 08:31:38 -0700
Bugs item #442758, was opened at 2001-07-19 07:29
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=442758&group_id=5470
Category: type/class unification
Group: Python 2.2
>Status: Open
Resolution: Wont Fix
Priority: 3
Submitted By: Walter Dörwald (doerwalter)
Assigned to: Guido van Rossum (gvanrossum)
Summary: 2.2a1: New style classes and __cmp__
Initial Comment:
Implementing __cmp__ in a new style class doesn't seem
to have an effect:
----
class Foo:
def __cmp__(self, other):
print "foo", other
return 0
class Bar(object):
def __cmp__(self, other):
print "bar", other
return 0
Foo() == 42
Bar() == 42
----
This only prints:
foo 42
----------------------------------------------------------------------
>Comment By: Walter Dörwald (doerwalter)
Date: 2001-07-19 08:31
Message:
Logged In: YES
user_id=89016
OK, you're right, but I think at least the documentation
should should mention it.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2001-07-19 08:00
Message:
Logged In: YES
user_id=6380
Really? We don't warn if you define __foo__ either.
Now, a tool to aid in converting classes to the new style
might want to treat __cmp__ special. But I don't think that
the new style implementation itself ought to warn about
__cmp__. Of course, the documentation should list all the
special methods that *are* supported -- you'll find more
differences, e.g. __getattr__ and __setattr__ work
differently, and __del__ isn't supported (yet).
----------------------------------------------------------------------
Comment By: Walter Dörwald (doerwalter)
Date: 2001-07-19 07:57
Message:
Logged In: YES
user_id=89016
But then some kind of warning should be issued.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2001-07-19 07:50
Message:
Logged In: YES
user_id=6380
Since __cmp__ is being phased out in favor of rich
comparisons, I would consider this a feature. Do you agree?
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=442758&group_id=5470