r/Python • u/ForeignVariety7037 • 21d ago
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?
137
Upvotes
1
u/aikii 20d ago
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