[Python-3000] Error in PEP 3115?
Georg Brandl
g.brandl at gmx.net
Fri Jun 1 22:14:38 CEST 2007
In PEP 3115 (the new metaclasses PEP), there is an example metaclass:
# The metaclass
class OrderedClass(type):
# The prepare function
@classmethod
def __prepare__(metacls, name, bases): # No keywords in this case
return member_table()
# The metaclass invocation
def __init__(self, name, bases, classdict):
# Note that we replace the classdict with a regular
# dict before passing it to the superclass, so that we
# don't continue to record member names after the class
# has been created.
result = type(name, bases, dict(classdict))
result.member_names = classdict.member_names
return result
Shouldn't __init__ be __new__? Also, if type(...) and not
type.__new__(self, ...) is called, the type of a class using this
metaclass will be type, not OrderedClass, but this may be intended.
Georg
--
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.
More information about the Python-3000
mailing list