1.__qualname__
A dotted name showing the “path” from a module’s global scope to a class, function or method defined in that module, as defined in PEP 3155. For top-level functions and classes, the qualified name is the same as the object’s name:
一个显示从从定义该对象的模块到到达该对象(类,函数,方法)所经路径的带.号的名字?对于top-level的类和方法,该名字就是该对象的名字。
在IDLE上运行的例子:
>>> class C: print("hi") class D: print("D") hi D >>> a = C() >>> print(a.D) <class '__main__.C.D'> >>>
下面的这个例子来自官方www.python.org
>>> class C: ... class D: ... def meth(self): ... pass ... >>> C.__qualname__ 'C' >>> C.D.__qualname__ 'C.D' >>> C.D.meth.__qualname__
'C.D.meth'