Skip to content
Advertisement

Tag: getattr

__getattr__ for static/class variables

I have a class like: Whenever MyClass.Foo or MyClass.Bar is invoked, I need a custom method to be invoked before the value is returned. Is it possible in Python? I know it is possible if I create an instance of the class and I can define my own __getattr__ method. But my scnenario involves using this class as such without

Advertisement