def TaggingDecorator(method):
    """Decorate the method with an attribute to let the metaclass know it's there."""
method.my_attr = 'FOO BAR'
return method


class TaggingMetaclass(type):
    """Metaclass to check for tags from TaggingDecorator and add them to the class."""

def __new__(cls, name, bases, dct):
    has_tag = False
for member in dct.values():
    if hasattr(member, 'my_attr'):
        has_tag = True
break
if has_tag:
    dct['my_attr'] = 'FOO BAR'
return type.__new__(cls, name, bases, dct)
Python - decorator - trying to access the parent class of a method