Message150312
PEP 3155 added qualified name as __qualname__ attribute in classes and functions. It would be useful if qualified name was also available as co_qualname attribute of code objects.
>>> import sys
>>> class A:
... def f1():
... return B.f2()
...
>>> class B:
... def f2():
... return sys._getframe(1)
...
>>> A.f1.__name__
'f1'
>>> A.f1.__qualname__
'A.f1'
>>> B.f2.__name__
'f2'
>>> B.f2.__qualname__
'B.f2'
>>> frame = A.f1()
>>> frame
<frame object at 0x7f9c1adca3a0>
>>> frame.f_code
<code object f1 at 0x7f9c1ae4be40, file "<stdin>", line 2>
>>> frame.f_code.co_name
'f1'
>>> frame.f_code.co_qualname
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'code' object has no attribute 'co_qualname'
Suggested behavior:
>>> frame.f_code.co_qualname
'A.f1' |
|
Date |
User |
Action |
Args |
2011-12-28 19:20:00 | Arfrever | set | recipients:
+ Arfrever, pitrou |
2011-12-28 19:20:00 | Arfrever | set | messageid: <1325100000.16.0.854542819355.issue13672@psf.upfronthosting.co.za> |
2011-12-28 19:19:59 | Arfrever | link | issue13672 messages |
2011-12-28 19:19:59 | Arfrever | create | |
|