python-异常

it2022-05-11  51

python-异常

实例:https://www.cnblogs.com/tangpg/p/7992979.html

 

在系统内部,解释器使用一种被称为 ‘块栈’的结构处理异常逻辑。它和执行栈一起被栈帧管理。块栈在运行期间,相关指令会提前将跳转位置信息存储到块栈,需要的时候从中获取。

调试: __debug__

test.py

def test(): if __debug__: print('debug') global x else: print('else') x = 10101 test() print(x) import dis dis.dis(test) >>> python -O test.py # -O是启动解释器优化模式,致使debug=0,但代码分析器依然认为x 为全局变量 else 10101 227 0 LOAD_GLOBAL 0 (print) 2 LOAD_CONST 1 ('else') 4 CALL_FUNCTION 1 6 POP_TOP 228 8 LOAD_CONST 2 (10101) 10 STORE_GLOBAL 1 (x) # 编译器忽略了 12 LOAD_CONST 0 (None) 14 RETURN_VALUE

 

posted on 2018-09-03 17:19 .Tang 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/tangpg/p/9579595.html


最新回复(0)