TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Member-only story

Actual, practical uses for the walrus operator in Python (+ examples)

Mike Huls
TDS Archive
Published in
7 min readJun 14, 2021

--

Is the walrus just made of sugar or is there more to it? (image by Mali Maeder on Pexels)

0. What is the walrus operator?

beerPrice = 9.99
print(beerPrice)
print(beerPrice := 9.99)

1. Use cases for the walrus operator

Let’s put this fella to work (image by NOAA on Unsplash)

Setup

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Mike Huls
Mike Huls

Written by Mike Huls

I write about interesting programming-related things: techniques, system architecture, software design and how to apply them in the best way. — mikehuls.com

Responses (1)