are user defined classes hashable?

Aahz aahz at
Tue Jul 21 04:53:08 CEST 2009

In article <373d6c69-6965-4a88-bdd2-8028ef850bf8 at>,
Hyuga  <hyugaricdeau at> wrote:
>Regardless, Nicolas's example can be applied to the class too:
>>>> class Foo(object):
>	pass
>>>> hash(Foo)
>>>> id(Foo)
>class objects are just objects of type 'type'.

Not quite.  They certainly default that way, but changing the metaclass
changes a class's type::

class M(type): 

class C(object): 

class C2(object):
    __metaclass__ = M

print type(C)
print type(C2)
Aahz (aahz at           <*>

"The volume of a pizza of thickness 'a' and radius 'z' is
given by pi*z*z*a"

More information about the Python-list mailing list