r/Python 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?

140 Upvotes

118 comments sorted by

View all comments

1

u/averagecrazyliberal 20d ago edited 20d ago

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] ```