Shorten Your Code Significantly in Python With The Walrus Operator

preview_player
Показать описание
This might be the first time you hear about the walrus operator. Well, it was introduced to us in Python 3.8 and still hasn't become incredibly common just yet, but that doesn't mean it's existence should be ignored.

Just as with list comprehensions, when use correctly, the walrus operator can significantly shorten the amount lines needed in your code.
Рекомендации по теме
Комментарии
Автор

Returning the result of the assignment is probably better wording that “displaying it”.

kingoreo
Автор

It is a great feature, which was missing in Python. Most common use case for me is when using regular expressions. Unfortunately in majority of production machines I am still limited to Python 3.6 for now.

movaxh
Автор

Its not that it assigns and DISPLAYS it is that it assigns or creates the variable and afterwards evaluates the expression its in, in this case is evaluated as the value of the key value pair.

ZeroSleap
Автор

I want to learn Python, there are many playlists in your channel, how do I begin sequentially?

Thanks.

abc_cba
Автор

The only problem I see is when you will try to debug/modificate!

higiniofuentes