>>> def fa():
... x = 520
... def fb():
... x = 880
... print('SSSS',x)
... print('aaaa',x)
...
>>> fa.__code__.co_consts
(None, 520, <code object fb at 0x7f31f682cb30, file "<stdin>", line 3>, 'fa.<locals>.fb', 'aaaa')
>>> fa.__code__.co_consts[2]
<code object fb at 0x7f31f682cb30, file "<stdin>", line 3>
>>> fa.__code__.co_consts[2]()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'code' object is not callable
>>> import code
>>> code.InteractiveInterpreter().runcode(fa.__code__.co_consts[2])
SSSS 880
>>>
|