Python Assignment Expressions and Using the Walrus Operator (Overview)
Each new version of Python adds new features to the language. For Python 3.8, the biggest change is the addition of assignment expressions. Specifically, the :=
operator gives you a new syntax for assigning variables in the middle of expressions. This operator is colloquially known as the walrus operator.
This course is an in-depth introduction to the walrus operator. You’ll learn some of the motivations for the syntax update and explore some examples where assignment expressions can be useful.
In this course, you’ll learn how to:
- Identify the walrus operator and understand its meaning
- Understand use cases for the walrus operator
- Avoid repetitive code by using the walrus operator
- Convert between code using the walrus operator and code using other assignment methods
- Understand the impacts on backward compatibility when using the walrus operator
- Use appropriate style in your assignment expressions
00:00 The Walrus Operator: Python Assignment Expressions.
00:06 Each new version of Python adds new features to the language. For Python 3.8, the biggest change was the addition of assignment expressions. Specifically, the operator gives you a new syntax for assigning variables in the middle of expressions.
00:21 This operator is colloquially known as the walrus operator. This video course is an in-depth introduction to the walrus operator. You will learn some of the motivations for the syntax update and explore some examples where assignment expressions can be useful. In this video course, you’ll learn how to identify the walrus operator and understand its meaning, understand use cases for the walrus operator, avoid repetitive code by using the walrus operator, convert between code using the walrus operator and code using other assignment methods, understand the impact on backwards compatibility when using the walrus operator, and use appropriate style in your assignment expressions.
01:09 So now you know what you’re going to cover. Let’s get started by looking at the fundamentals of the walrus operator.
Become a Member to join the conversation.