New style classes and rich comparison
Michael Hudson
mwh at python.net
Thu Dec 18 09:35:15 EST 2003
stain at stud.ntnu.no (Stian Søiland) writes:
> Could anyone explain to me why this does not work as intended?
[snippo]
> It seems that __eq__ is fetched directly from newbie's class, not from
> newbie.
Yup! One of the differences between new-style and old-style classes.
To see why something has to be a bit like this, consider the
difference between a unbound method for the instance and a bound
method for the *type* of the instance...
[biggo snippo]
> Can I use __metaclass__ or something?
I think that's what you want, yes.
Cheers,
mwh
--
Ignoring the rules in the FAQ: 1" slice in spleen and prevention
of immediate medical care.
-- Mark C. Langston, asr
More information about the Python-list
mailing list