I have this class:
class ReallyLongClassName:
static_var = 5
def instance_method(self):
ReallyLongClassName.static_var += 1
Is there some way to access the static variable using the self variable?
I'd rather do something like class(self).static_var += 1
, because long names are unreadable.
Use self.__class__.classAttr
. This should work for both old & new style classes.