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·我们的愿景·广告投放·感谢·实用小工具· 890 人在线最高记录 5168· Select Language
World is powered by solitude
VERSION: 188.8.131.52 · 20ms · UTC 19:45 · PVG 03:45 · LAX 11:45 · JFK 14:45 ♥ Do have faith in what you're doing.