For more information on concepts covered in this lesson, you can check out:
00:00 Hello, Walrus! Often, the best way to get a handle on a new idea in Python is to use the REPL. In this video course, you’ll see the bpython enhanced REPL being used because it offers color coding, command completion, and other benefits.
Once again, we can inspect the value of
walrus by typing its name in the REPL. It returns the value
True. You might be wondering why parentheses are needed for this second version, and you’ll learn why later on in the course.
You may have noticed this earlier in the REPL code seen onscreen when the walrus example was entered and the value
True was returned. You can see another important aspect about the walrus operator in this example.
01:37 Although it might look new, the walrus operator doesn’t do anything that isn’t possible without it. It just makes certain constructs more convenient and can sometimes communicate the intent of your code more clearly.
01:51 Now you have a basic idea of what the walrus operator is and what it can do. It’s an operator used in assignment expressions, which can return the value being assigned, unlike traditional assignment statements.
Become a Member to join the conversation.