
Sept. 26, 2007
9:42 p.m.
What's the most compact way to repeatedly call a function on a list without accumulating the results? While I can accumulate results via a = [f(x) for x in mylist] or with a generator, there doesn't seem to be a way to do this without accumulating the results. I guess I need to either use the above and ignore the result, or use for x in mylist: f(x) I run into this need quite frequently. If I write [f(x) for x in mylist] with no assignment, will Python notice that I don't want the accumulated results and silently toss them for me? A possible syntax change would be to allow the unadorned f(x) for x in mylist And raise an error if someone tries to assign to this. Terry