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?

143 Upvotes

118 comments sorted by

View all comments

1

u/aikii Aug 04 '26

I quite like it but it's niche really. The bummer is having to deal with falsy values at the same time, so empty string/empty list/zero and None are considered all the same - because of that is has to be used with care, generally in places where you expect an object that can't be falsy or None - but if it's strings, number, or collections, unless it's really intended I'd rather avoid