In Python, try/except is commonly used for control flow, and not just for error han‐ dling. There’s even an acronym/slogan for that documented in the official Python glos‐ sary: EAFP Easier to ask for forgiveness than permission. This common Python coding style assumes the existence of valid keys or attributes and catches exceptions if the as‐ sumption proves false. This clean and fast style is characterized by the presence of many try and except statements. The technique contrasts with the LBYL style com‐ mon to many other languages such as C.
关于·FAQ·API·我们的愿景·广告投放·感谢·实用小工具· 2904 人在线最高记录 5043· Select Language
World is powered by solitude
VERSION: 18.104.22.168 · 22ms · UTC 11:42 · PVG 19:42 · LAX 03:42 · JFK 06:42 ♥ Do have faith in what you're doing.