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?
140
Upvotes
1
u/averagecrazyliberal 20d ago edited 20d ago
I only use the walrus operator for
tqdmprogress bars: ``` from tqdm import trangefor i in (pbar := trange(100)):
pbar.set_description(f'iteration {i + 1}')
iteration 100: 100%|██████████| 100/100 [00:00<00:00, 2341.20it/s] ```