decorating classes with metaclass

Discussion in 'Python' started by Bengt Richter, Mar 14, 2005.

  1. 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
    Bengt Richter, Mar 14, 2005
    #1
    1. Advertising

  2. 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.
    Simon Percivall, Mar 15, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robin Becker
    Replies:
    0
    Views:
    282
    Robin Becker
    Feb 15, 2005
  2. ironfroggy
    Replies:
    16
    Views:
    438
    Michele Simionato
    Jun 3, 2005
  3. Daniel Nogradi

    module wide metaclass for new style classes

    Daniel Nogradi, Dec 16, 2006, in forum: Python
    Replies:
    3
    Views:
    275
    Daniel Nogradi
    Dec 17, 2006
  4. Replies:
    0
    Views:
    224
  5. Steven D'Aprano

    Metaclass of a metaclass

    Steven D'Aprano, Jun 5, 2012, in forum: Python
    Replies:
    1
    Views:
    305
Loading...

Share This Page