In my current codebase, I have the following line where to_remove
is a set
[to_remove.update(b) for b in some_set if all(a <= b for a in some_dict)]
Although it works, it bothers me a little bit since it creates a list of None
which is not used. Is it considered not standard? Is there a better way to do it?
Update:
Since it has been pointed out that list comprehension solely for side effect is not good, I have changed my code to
to_remove.update(itertools.chain.from_iterable(
b for b in some_set if all(a <= b for a in some_dict))