Q:

List comprehensions for side effects - idiomatically correct or an abomination? 

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?  

A:

List comprehensions are for creating a list.  That's not what you're doing here, so I'd avoid it. 

A:

Personally, I would do
for cheese in cheeses:
    cheese.out_of_stock()

This feels a bit more explicit to me.  It's another line, but I suspect that another programmer reading that code would understand it well, whereas the list comprehension version might be slightly confusing.  In addition, I could imagine that someone else might come along later (not knowing that out_of_stock doesn't return a value) and try to use that list later. 
I guess there's nothing wrong with it, though.  Ultimately, it comes down to who's going to be reading that code later (yourself or others) and whether or not they'll know what's going on. 
EDIT: Also, you're using a lovely functional programming construct taken from Haskell to do nasty stateful things...

A:

Semantically, if cheese.out_of_stock returned a boolean, then it would be fine.   However this is not very recommended if cheese.out_of_stock does not return a value, then it would be very confusing and unmaintainable. 
import this

for more information

