Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Hello, Walrus!

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.

00:20 All the code which is entered in this course is standard Python, and you can do so in the standard Python REPL, which is typically accessed from your command line by typing python or python3.

00:32 This first line is a traditional assignment statement, where the value False is assigned to the walrus variable.

00:41 It can be inspected by typing the variable’s name in the REPL, and the value is returned. Here, it’s False. Next, an assignment expression is used to assign the value True to walrus.

00:58 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.

01:14 There’s a subtle but important difference between the two types of assignments just seen. An assignment expression returns the value while the traditional assignment doesn’t.

01:25 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.

02:05 In the next section, you’ll get deeper and really learn about the walrus operator—firstly, by seeing the motivation behind its introduction.

Become a Member to join the conversation.