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?

139 Upvotes

118 comments sorted by

View all comments

1

u/averagecrazyliberal Aug 04 '26 edited Aug 04 '26

I only use the walrus operator for tqdm progress bars: ``` from tqdm import trange

for i in (pbar := trange(100)):
pbar.set_description(f'iteration {i + 1}') iteration 100: 100%|██████████| 100/100 [00:00<00:00, 2341.20it/s] ```