python-function
1 # -*- coding: utf-8 -*- 2 def check_func(a): 3 print("__name__:",a.__name__) 4 print("__doc__:",a.__doc__) 5 print("__qualname__:",a.__qualname__) 6 print("__defaults__:",a.__defaults__) 7 print("__code__:",a.__code__) 8 print("__globals__:",a.__globals__) 9 print("__dict__:",a.__dict__) 10 print("__closure__:",a.__closure__) 11 print("__annotations__:",a.__annotations__) 12 print("__kwdefaults__:",a.__kwdefaults__) 13 def func_1(): 14 pass 15 def func_2(arg="argsss"): 16 "it's func_2" 17 a = "func" 18 b = NotImplemented 19 c = ... 20 "it's func2" 21 def func_2_1(): 22 "it's func_2_1 in scope of func_2" 23 24 a = func_1 25 check_func(a) 26 a = func_2 27 check_func(a) 28 """ 29 运行结果: 30 """
运行结果:
__name__: func_1 __doc__: None __qualname__: func_1 __defaults__: None __code__: <code object func_1 at 0x01002A70, file "E:\mine\pythonPrac.py", line 13> __globals__: {'__package__': None, 'a': <function func_1 at 0x0102CE88>, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__doc__': None, 'check_func': <function check_func at 0x010047C8>, '__file__': 'E:\\mine\\pythonPrac.py', 'func_2': <function func_2 at 0x00FF8858>, 'func_1': <function func_1 at 0x0102CE88>, '__builtins__': <module 'builtins' (built-in)>, '__name__': '__main__'} __dict__: {} __closure__: None __annotations__: {} __kwdefaults__: None __name__: func_2 __doc__: it's func_2 __qualname__: func_2 __defaults__: ('argsss',) __code__: <code object func_2 at 0x01011D40, file "E:\mine\pythonPrac.py", line 15> __globals__: {'__package__': None, 'a': <function func_2 at 0x00FF8858>, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__doc__': None, 'check_func': <function check_func at 0x010047C8>, '__file__': 'E:\\mine\\pythonPrac.py', 'func_2': <function func_2 at 0x00FF8858>, 'func_1': <function func_1 at 0x0102CE88>, '__builtins__': <module 'builtins' (built-in)>, '__name__': '__main__'} __dict__: {} __closure__: None __annotations__: {} __kwdefaults__: None