[Python-3000] PEP for Metaclasses in Python 3000 (original) (raw)
Talin talin at acm.org
Sat Mar 10 10:21:46 CET 2007
- Previous message: [Python-3000] PEP for Metaclasses in Python 3000
- Next message: [Python-3000] PEP for Metaclasses in Python 3000
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Greg Ewing wrote:
Talin wrote:
class Foo(base1, base2, metaclass=mymeta): ... -1 on this syntax, I think it's ugly.
All I can say is, beauty is in the eye, etc...in any case, I'm not the one to decide what's pretty and what's not.
Alternative proposals:
class Foo(base1, base2) as MyMeta: ... or class Foo(base1, base2) = MyMeta: ...
Neither of these work for me, in the sense that when I read them, they don't elicit concepts that match the metaclass concept. The relation between a class and a metaclass isn't well-expressed with 'as', 'is', or 'equals'.
class Foo(base1, base2, metaclass=mymeta, private=True): ... class Foo(base1, base2) as MyMeta(private=True): ... or class Foo(base1, base2) = MyMeta(private=True): ...
This attribute is a method named metacreate Very bad choice of name -- it's not creating a meta-anything, and gives no clue what it is creating.
I didn't want to call it metadict, as it was in the earlier proposal, because in the current version it's doing more than just creating the class dict, it's also processing any additional keywords that are passed in to the class base list.
It would be possible to leave the existing metaclass syntax in place. Alternatively, it would not be too difficult to modify the syntax rules of the Py3K translation tool to convert from the old to the new syntax. The existing syntax actually has some advantages, e.g. you can do things like class Foo: class metaclass: # Real class methods defined here which I think is rather elegant, so I'm not sure I'd like the new syntax to completely replace the old one.
I have no opinion on this - I've never had a need to declare a metaclass inline like that.
-- Greg
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/talin%40acm.org
- Previous message: [Python-3000] PEP for Metaclasses in Python 3000
- Next message: [Python-3000] PEP for Metaclasses in Python 3000
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]