我理解以下Python代码:
>>> class A(object):
... def __str__(self):
... return "An instance of the class A"
...
>>>
>>> a = A()
>>> print a
An instance of the class A
Run Code Online (Sandbox Code Playgroud)
现在,我想改变输出
>>> print A
<class '__main__.A'>
Run Code Online (Sandbox Code Playgroud)
我需要哪个函数来重载才能做到这一点?即使从未实例化类,解决方案也必须工作.Python 2.x和3中的情况有所不同吗?