decorating classes with metaclass

B

Bengt Richter

Just wondering whether anyone has discussed using decorator
syntax to effect metaclass processing. E.g.

@MC
class Foo(object):
pass

would have the same effect as

class Foo(object):
__metaclass__ = MC
pass

ISTM fairly analogous to function decoration, just
differing in the arguments passed.

Regards,
Bengt Richter
 
S

Simon Percivall

Class decoration was discussed back when (you can search for the thread
in python-dev); not as an alias to metaclasses but discussed as having
exactly the same semantics as function decoration. Maybe the idea has
more merit as being another way of setting the __metaclass__ attribute;
on the other hand: it doesn't increase visibility and what is does and
how it does it is very different from that of function decoration; so
perhaps not.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top