Amandine Lee Passing Exceptions 101 Paradigms in Error Handling PyCon 2017

  Рет қаралды 5,726

PyCon 2017

PyCon 2017

Күн бұрын

"Speaker: Amandine Lee
Exception handling in Python can sometimes feel like a Wild West. If you have a `send_email` function, and the caller inputs an invalid email address, should it:
A) Return `None` or some other special return value,
B) Let the underlying exception it might cause bubble up,
C) Check via a regex and type checking and raise a `ValueError` immediately, or
D) Make a custom `EmailException` subclass and raise that?
What if there is a network error while the email was sending? Or what if the function calls a helper `_format_email` that returns an integer (clearly wrong!), or raises an `TypeError` itself? Should it crash the program or prompt a retry?
This talk will introduce the concept of an exception, explain the built-in Python exception hierarchy and the utility of custom subclasses, demonstrate try/except/finally/else syntax, and then explore different design patterns for exception control flow and their tradeoffs using examples. It will also make comparisons to error handling philosophy in other languages, like Eiffel and Go.
Slides can be found at: speakerdeck.com/pycon2017 and github.com/PyCon/2017-slides"

Пікірлер: 7
@stalinthomas9850
@stalinthomas9850 3 жыл бұрын
00:51 Introduction 03:17 Exception 06:35 Reasons for exceptions 09:52 Exception use cases 13:46 Design by Contract 17:42 Recovering from errors 23:49 Lessons Learned 25:29 QnA
@Ryndae-l
@Ryndae-l 7 жыл бұрын
It's a shame that there was no talk about the Common Lisp condition system, which I think you can take inspiration from, seeing that python is already a dynamic language and has closures support...
@hardkrash
@hardkrash 6 жыл бұрын
The last data i read about the “try/catch” vs. “if in” for performance was around 10% or less of your tests are going to hit then use try/catch. Unfortunately I can’t find that reference.
@Ryndae-l
@Ryndae-l 7 жыл бұрын
You can catch a SyntaxError coming from an import, from eval, etc. But yeah, you can't catch it if your error is in the same module, because the module code hasn't even started to run when the error is emited.
@piertoni
@piertoni 6 жыл бұрын
This talk Is understandable with 0.75 speed option :)
@RoamingAdhocrat
@RoamingAdhocrat 3 жыл бұрын
I like to think that in her free time, the speaker pursues her passion of being an auctioneer...
@amandinelee4962
@amandinelee4962 5 ай бұрын
@@RoamingAdhocrat I've thought about it :) Or impressively fast rapping.
Eric Evenchick   Hacking Cars with Python   PyCon 2017
29:48
PyCon 2017
Рет қаралды 15 М.
Summer shower by Secret Vlog
00:17
Secret Vlog
Рет қаралды 12 МЛН
Smart Sigma Kid #funny #sigma #comedy
00:26
CRAZY GREAPA
Рет қаралды 22 МЛН
New model rc bird unboxing and testing
00:10
Ruhul Shorts
Рет қаралды 27 МЛН
Trey Hunner   Readability Counts   PyCon 2017
27:11
PyCon 2017
Рет қаралды 11 М.
Brandon Rhodes   The Dictionary Even Mightier   PyCon 2017
47:22
PyCon 2017
Рет қаралды 31 М.
Jukka Lehtosalo, David Fisher   Static Types for Python   PyCon 2017
49:31
Benny Bauer   Python in The Serverless Era   PyCon 2017
30:47
PyCon 2017
Рет қаралды 9 М.
"I Hate Agile!" | Allen Holub On Why He Thinks Agile And Scrum Are Broken
8:33
Nature's Incredible ROTATING MOTOR (It’s Electric!) - Smarter Every Day 300
29:37
Summer shower by Secret Vlog
00:17
Secret Vlog
Рет қаралды 12 МЛН