On 3/14/07, Talin <[EMAIL PROTECTED]> wrote:
> PEP: xxx
> Title: Metaclasses in Python 3000
Looks good.
> # The metaclass
> class OrderedClass(type):
>
> # The custom dictionary
> class member_table(dict):
> def __init__(self):
> self.member_names = []
>
> def __setitem__(self, key, value):
> # if the key is not already defined, add to the
> # list of keys.
> if key not in self:
> self.member_names.append( key )
>
> # Call superclass
> dict.setitem(self, key value)
Should probably be ``dict.__setitem__(self, key, value)``.
> # The prepare function
> @classmethod
> def __prepare__(cls, name, bases): # No keywords in this case
> return self.member_table()
Should probably be:
@classmethod
def __prepare__(meta, name, bases):
return meta.member_table()
Perhaps __prepare__ should be special-cased like __new__ so that it's
always a @classmethod?
STeVe
--
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
--- Bucky Katt, Get Fuzzy
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com