quantifiedcode / python-anti-patterns

An open collection of Python anti-patterns and worst practices.
https://quantifiedcode.github.io/python-anti-patterns
Other
1.72k stars 249 forks source link

Calling LBYL an anti-pattern is not exactly correct #125

Open tucked opened 5 years ago

tucked commented 5 years ago

https://mail.python.org/pipermail/python-dev/2014-March/133118.html

I disagree with the position that EAFP is better than LBYL, or "generally recommended" by Python. (Where do you get that? From the same sources that are so obsessed with DRY they'd rather introduce a higher-order-function than repeat one line of code? :-)

IMO, the primary motivation for EAFP over LBYL is avaoiding TOCTOU bugs.