[Python-3000] Error in PEP 3115?

Guido van Rossum guido at python.org
Sat Jun 2 01:18:47 CEST 2007


You're right. Fixed now. I also fixed dict.setitem (should be
dict.__setitem__). Thanks for noticing!

--Guido

On 6/2/07, Georg Brandl <g.brandl at gmx.net> wrote:
> 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.
>
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list