I have the following:
class X(object):
def __init__(self, *args, **kwargs):
type(self).label_type = xyzzy(self.__class__.__name__)
class Y(X):
def __init__(self, *args, **kwargs):
super(Y, self).__init__(self, *args, **kwargs)
When I create a new instance of Y, a class variable called label_type
is created using Y
, not X
. This is good and works fine.
But it burns me that I have to wait until there's an instance of Y before the class variable is created. How can I set label_type
when class Y is compiled, not when it is instantiated?
EDIT - I have numerous subclasses that are derived from X. I want to push as much of the work into X as possible.