Metaclasses and new-style classes
Robert Kern
rkern at ucsd.edu
Mon Aug 8 01:59:53 EDT 2005
Jan-Ole Esleben wrote:
> Hi!
>
> I've just posted a question about metaclasses in ZOPE on the ZOPE
> list, and one of the replies said that metaclasses (at least
> "painless" metaclasses) cannot be used without new-style classes (or
> rather, that they don't work where you cannot explicitly use new-style
> classes). I haven't so far been able to find _anything_ on the subject
> - what is true here?
http://docs.python.org/ref/metaclasses.html
http://www.python.org/2.2.3/descrintro.html
In short, yes. The preferred method for making metaclasses requires
new-style classes. There is an older method which uses what is called
the Don Beaudry hook; Zope used to use it extensively before Python 2.2.
You should avoid using that older method and stick to new-style classes.
--
Robert Kern
rkern at ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the Python-list
mailing list