
Terry Jones wrote:
What's the most compact way to repeatedly call a function on a list without accumulating the results?
for x in mylist: f(x)
That's it.
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?
No. And there would be no advantage in using LC syntax even if it did. The generated bytecode would be essentially identical. If you really must have it all on one line, you can write for x in mylist: f(x) -- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | Carpe post meridiem! | Christchurch, New Zealand | (I'm not a morning person.) | greg.ewing@canterbury.ac.nz +--------------------------------------+