Comprehensions can be of the list or generator variety (or for that matter sets and dictionaries in modern Python).
Let me show you what I meant:
EDIT: to clarify, the link I have here says that the original docs didn't say "generate comprehension" but calls for people to use the term. I don't want to dig into this particular terminology argument, but I think it's a reasonable term, I think Ned is a good Python authority, and the rest of my points about indirection still stand.
Let me show you what I meant:
Output:>>> for n in range(10, 0, -2):
... print(n)
...
10
8
6
4
2
It produces the same output as yours, minus the comprehension, minus the lambda. I don't understand what benefit there is to including them when you can skip them without any issues.EDIT: to clarify, the link I have here says that the original docs didn't say "generate comprehension" but calls for people to use the term. I don't want to dig into this particular terminology argument, but I think it's a reasonable term, I think Ned is a good Python authority, and the rest of my points about indirection still stand.