. test test . inspect , : Python ?
, test :
def test(arg1='foo'):
print test.__defaults__[0]
Will output foo. But the link to testwill only work until it is testactually defined:
>>> test()
foo
>>> other = test
>>> other()
foo
>>> del test
>>> other()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in test
NameError: global name 'test' is not defined
So, if you are going to transfer this function, you really need to go to the route inspect: (
source
share