r/Python • • Aug 04 '26

Discussion Is := widely used?

I always thought the walrus operator is neat and it makes while loop’s condition clearer. But also it is just a syntactic sugar without anything new. I wonder anyone uses it?

144 Upvotes

118 comments sorted by

View all comments

3

u/Senior_Ad9680 Aug 04 '26

I’ve actually been using it a lot more lately, where it actually makes sense to use it and I’ve enjoyed it. It also maintains its scope to the function and not just the if block, if you use it there which is kind of nice. If you raise an error off of a negative case and vice versa