Question about accessing class-attributes.
staschuk at telusplanet.net
Tue Apr 29 18:18:42 CEST 2003
Quoth Michael Hudson:
> mis6 at pitt.edu (Michele Simionato) writes:
> > 2) why you say this makes classes unhashable ?
> Well, I thought it would. I was wrong:
> Then you get this kind of weirdness:
> />> class C(type):
> |.. def __eq__(self, other):
> |.. return 1
Can't the instances of this metaclass be made sensible for use in
dicts simply with
for example? (To ensure that if x == y then hash(x) == hash(y),
as desired.) Or does this do weird things in a metaclass context?
(Ignoring issues arising from the brokenness of the __eq__:
__metaclass__ = C
foo() == 3 # true!
hash(foo()) == hash(3) # probably false
and like cases.)
Steven Taschuk staschuk at telusplanet.net
"Its force is immeasurable. Even Computer cannot determine it."
-- _Space: 1999_ episode "Black Sun"
More information about the Python-list