Passing attribute to parent class via child in decorator

39 views Asked by At

I have this class hierarchy

class ParentMeta(type):
    def __new__(v1, name, b, x):
        # some code
        return super(ParentMeta, v1).__new__(v1, name, b, x)

and then

class ServiceMeta(ParentMeta, AnotherServiceMeta):
    pass

The ServiceMeta is normally used as a decorator in add_metaclass i.e.,

@add_metaclass(ServiceMeta)
class MyService(object):
    """ Code

The question i want to ask that how can i pass name attribute here? The name attribute is part of ParentMeta.

EDIT:

Link to add_metaclass documentation: https://six.readthedocs.io/#six.add_metaclass

By default, the ServiceMeta is picking up MyService as name for the class. I want to modify this behavior. For that reason i want to pass name value in decorator.

0

There are 0 answers