On Oct 6, 7:02 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > Fuzzyman wrote: > > On Oct 5, 11:54 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > >> Fuzzyman wrote: > >>> Hello all, > >>> I may well be being dumb (it has happened before), but I'm struggling > >>> to fix some code breakage with Python 2.6. > >>> I have some code that looks for the '__lt__' method on a class: > >>> if hasattr(clr, '__lt__'): > >>> However - in Python 2.6 object has grown a default implementation of > >>> '__lt__', so this test always returns True. > >>>>>> class X(object): pass > >>> ... > >>>>>> X.__lt__ > >>> <method-wrapper '__lt__' of type object at 0xa15cf0> > >>>>>> X.__lt__ == object.__lt__ > >>> False > >> In 3.0, the test returns true because function attributes only get > >> wrapped when bound. In the meanwhile, " 'object' in repr(X.__lt__)" > >> should do it for you. > > So long as its never used on a class with 'object' in the name. > > Doesn't sound like a particularly *good* solution to me. :-) > > From what you posted, 'type object at' should work.
It's still a hack... -- http://mail.python.org/mailman/listinfo/python-list