metaclasses -- aka Don Beaudry hook/hack

Skip Montanaro skip at pobox.com
Tue Jun 12 11:32:11 EDT 2001


    James> Before I head too deeply into Zope dependencies, I would be
    James> interested in knowing whether or not "type(MyClass) ==
    James> types.ClassType" and "isinstance(myInstance,MyClass)" work for
    James> classes derived from ExtensionClass.

Straight from the horse's mouth:

>>> type(gtk.GtkButton)
<extension class ExtensionClass.ExtensionClass at 402002e0>
>>> type(gtk.GtkButton) == types.ClassType
0
>>> isinstance(gtk.GtkButton(), gtk.GtkButton)
1

    James> (And if so, why do these work for C extension classes using the
    James> Don Beaudry hook but not for Python classes using the same hook?)

You'll have to ask someone with more subject knowledge.  (Don would probably
be a good start.  ;-) I've cc'd python-dev because the experts in this area
are all there.

-- 
Skip Montanaro (skip at pobox.com)
(847)971-7098




More information about the Python-list mailing list