Python3没有';是否不显示已更改的_名称_属性?
我不知道Python 3做出了这样的改变Python3没有';是否不显示已更改的_名称_属性?,python,python-3.x,Python,Python 3.x,我不知道Python 3做出了这样的改变 Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. >>> def f(): pass >>> f.__name__ = 'g' >>> f <
Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> def f():
pass
>>> f.__name__ = 'g'
>>> f
<function g at 0x000000000264C6D8>
win32上的Python 2.7.5(默认,2013年5月15日,22:44:16)[MSC v.1500 64位(AMD64)]
有关详细信息,请键入“copyright”、“credits”或“license()”。
>>>def():
通过
>>>f.uuu名称uuu='g'
>>>f
在Python 3中:
Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:06:53) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> def f():
pass
>>> f.__name__ = 'g'
>>> f
<function f at 0x0000000003335AE8>
win32上的Python 3.3.2(v3.3.2:d047928ae3f6,2013年5月16日,00:06:53)[MSC v.1600 64位(AMD64)]
有关详细信息,请键入“copyright”、“credits”或“license()”。
>>>def():
通过
>>>f.uuu名称uuu='g'
>>>f
这样做的原因是什么?我遗漏了什么吗?改用
\uuuuuu qualname\uuuuu
:
>>> def f():
... pass
...
>>> f.__qualname__ = 'g'
>>> f
<function g at 0x0000000002AE5C80>
>>def():
... 通过
...
>>>f.uuu qualname_uuuu='g'
>>>f
根据:
函数和类的repr()
和str()
修改为使用
\uuuuuuqalname\uuuuuu
而不是\uuuuu name\uuuuuuu
另请参见:。请不要发布代码截图