2 ms·
For me the big thing is the case where you want to use a list comprehension with a somewhat expensive function: [func(x) for x in values if func(x) < 10] Y
by orf 8y ago
For me the big thing is the case where you want to use a list comprehension with a somewhat expensive function:
[func(x) for x in values if func(x) < 10]
You could break this into two comprehensions, sure, but it's annoying. With this:
[result for x in values if (result := func(x)) < 10]
- o10449366 8y agoAgreed. List comprehensions are where I see them being the most useful and where, in the past, I wished the functionality had existed.