有时我发现自己正在访问班级成员。在一个项目中,我什至在类定义中包含类定义。
在这种情况下,我经常发现mysql键入self.__class__.<member_name>
或self.__class__.<contained_class_name>
。在几乎所有用例中,self.__class__
比实际的类名更多的字符,因此使用self.__class__
很烦人。但是,
self.__class__.some_attribute
与(始终)与使用类名不同,例如MyClass.some_attribute
,我想要前者的行为所以我在想。有self.__class__
的缩写吗?