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.
https://mail.python.org/pipermail/python-dev/2014-March/133118.html
IMO, the primary motivation for EAFP over LBYL is avaoiding TOCTOU bugs.