Geek Culture
Published in

Geek Culture

Using Optionals in Python

Say ‘non’ to None.

Photo by Lacey Williams on Unsplash

There are often situations in code where a required value doesn’t exist. A typical way of dealing with this is to return None but optionals provide a cleaner way, and the optional.py module provides an easy-to-use implementation of optionals.

An example

For example, suppose we had a customer database, and we needed a function to find the…

--

--

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
Martin McBride

Martin McBride

247 Followers

Freelance software consultant, developer, technical author. Java, Python. martinmcbride.org