I have a list of cheese objects. Cheese has a method that does a bunch of stuff with the db and whatnot, called out_of_stock().
So:
[cheese.out_of_stock() for cheese in cheeses]
It feels sloppy to me. Like I’m doing something (creating a list) for a bunch of side effects (zeroing inventory).
Am I being foolish? Is this subjective to the method?
List comprehensions are for creating a list. That’s not what you’re doing here, so I’d avoid it.