What does EAFP mean?
Common pitfalls and best practices
Audio flashcard · 0:16Nortren·
What does EAFP mean?
0:16
EAFP stands for Easier to Ask Forgiveness than Permission. It is a Python idiom favoring try-except over checking conditions in advance with if. For example, instead of checking if a key exists in a dict and then accessing it, just access it and catch KeyError. EAFP is generally more Pythonic and often faster.
docs.python.org