class Meta(type):
def __new__(cls, name, bases, attrs):
# Generate a and b for the object based on x ?
return super().__new__(cls, name, bases, attrs)
class A(metaclass=Meta):
def __init__(self, a, b):
self.a = a
self.b = b
obj = A(x)
The x
passed to A
should be consumed with in the meta class Meta
, and it should generate the attributes a
& b
that are needed by the __init__
of A
. It is preferred for obj
not to have access to x
.
Not sure if its possible or valid, but is there a way to achieve it ?