Walrus Operator Pitfalls
For more information on concepts covered in this lesson, you can check out:
00:00 Walrus operator pitfalls.
00:04 The walrus operator is a new syntax that’s only available in Python 3.8 and later. This means that any code you write using it will only work on the most recent versions of Python.
00:16
If you need to support older versions of Python, then you can’t ship code that uses assignment expressions. There are some projects, like walrus
, that can automatically translate walrus operators into code that’s compatible with older versions of Python.
00:31 This allows you to take advantage of assignment expressions when writing your code and still distribute code that’s compatible with more Python versions.
00:41 Experience with the walrus operator indicates that it won’t revolutionize Python. Instead, using assignment expressions where they are useful can help you to make several small improvements to your code that can benefit your work overall.
00:54 There are many times where it will be possible to use the walrus operator where it won’t necessarily improve the readability or efficiency of your code.
01:03 In those cases, you’re better off writing your code in a more traditional manner.
01:09 Now that you’ve covered all the content in this course, let’s recap in the summary.
Become a Member to join the conversation.