Sometimes I find myself accessing class members. In one project I even had class definitions inside a class definition.
In such cases I often find mysql typing self.__class__.<member_name>
or self.__class__.<contained_class_name>
. In about all use cases self.__class__
is more characters than the actual class name, hence using self.__class__
is annoying. However,
- I don't want to hardcode the class name inside the class definition,
self.__class__.some_attribute
is not (always) the same as using the class name, e.g.MyClass.some_attribute
and I want the behaviour of the former
So I was wondering. Is there some shorter notation of self.__class__
?