GOTO 2019 • It Really is Easier to Ask for Forgiveness (than Permission) • Naomi Ceder51:02 403 views 50% Published 6 months ago
This presentation was recorded at GOTO Chicago 2019. #GOTOcon #GOTOchgo
Naomi Ceder - Chair of Python Software Foundation
It's a Pythonic maxim that "it's easier to ask for forgiveness than permission" and Pythonic code is written with a strong preference for attempting an operation and raising exceptions as needed. This contrasts with many languages which take a "look before you leap" approach where conditions, types, and values are checked in advance.
This tendency to raise exceptions first and ask questions later strikes coders from other languages (and even some Pythonistas) as reckless, strange, and inefficient. Wouldn't it be "better" to do a little checking and avoid exceptions? Exceptions can't be intended to be used so frequently, can they? Surely raising so many exceptions results in slow and inefficient code?
This talk will address all of those concerns. We'll show how and why Python's approach is a strength, not a weakness, which makes Python more expressive and flexible. We'll also see that raising exceptions is integral to Python, and underlies many common features of the language. Finally, we'll look at some simple tests that show that the Pythonic use of exceptions usually is faster [...]
Download slides and read the full abstract here: