[Python-3000] A plus for naked unbound methods
Mark Seaborn
mrs at mythic-beasts.com
Tue Oct 7 23:28:16 CEST 2008
Terry Reedy <tjreedy at udel.edu> wrote:
> Mark Seaborn wrote:
> > It appears that unbound methods do what you want in the general case
> > in Python 2.5 and 2.6. It's just that __lt__ behaves unlike normal
> > unbound methods. So this isn't an argument against unbound methods,
> > it's an argument for __lt__ not to be a special case.
>
> It is not a special case.
>
> >>> def C(object): pass
> ...
>
> >>> C.__hash__ == object.__hash__
> False
>
> >>> C.__str__ == object.__str__
> False
I assume you meant to use "class" instead of "def", in which case most
of the attributes do compare the way you want:
>>> class C(object): pass
...
>>> C.__hash__ == object.__hash__
True
>>> C.__str__ == object.__str__
True
# But in Python 2.6:
>>> C.__lt__ == object.__lt__
False
Mark
More information about the Python-3000
mailing list