Open in app
Jonathan Hsu
5.1K Followers
About

Sign in

5.1K Followers
About
Open in app
Several people have already mentioned that try/except is “more Pythonic” than checking first.
94
2

Tim Lantz

Jonathan Hsu

Jonathan Hsu

Jan 2, 2020·1 min read

Tim, I learned a lot from this comment — thank you!

Written by

Jonathan Hsu

Top writer with 1M+ views. Follow me at medium.com/code-85 and medium.com/growth-85

More from Jonathan Hsu

Top writer with 1M+ views. Follow me at medium.com/code-85 and medium.com/growth-85

More From Medium

A Simple Introduction to Python Virtual Environments

Jonathan Hsu in Code 85

How To Stop Floating Point Arithmetic Errors in Python

Jonathan Hsu in Code 85

How To Pass Command-Line Values to a Python Script

Jonathan Hsu in Code 85

Two Simple Algorithms for Chunking a List in Python

Jonathan Hsu in Code 85

Use Sets to Count Occurrences in Python

Jonathan Hsu in Code 85

A Beginner’s Guide to Python List Comprehensions

Jonathan Hsu in Code 85

Two Simple Ways to Count Backwards in Python

Jonathan Hsu in Code 85

4 Simple Ways to Refactor Your Python Code

Jonathan Hsu in Code 85

About

Help

Legal

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store