The Python Papers

The Python Papers

Share this post

The Python Papers
The Python Papers
Python 101 – Assignment Expressions
Copy link
Facebook
Email
Notes
More

Python 101 – Assignment Expressions

AKA: The Walrus Operator

Mike Driscoll's avatar
Mike Driscoll
Feb 19, 2025
∙ Paid
8

Share this post

The Python Papers
The Python Papers
Python 101 – Assignment Expressions
Copy link
Facebook
Email
Notes
More
1
Share

Assignment expressions were added to Python in version 3.8. The general idea is that an assignment expression allows you to assign to variables within an expression.

The syntax for doing this is:

NAME := expr

This operator has been called the “walrus operator”, although their real name is “assignment expression”. Interestingly, the CPython internals also r…

Keep reading with a 7-day free trial

Subscribe to The Python Papers to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Mike Driscoll
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share

Copy link
Facebook
Email
Notes
More