Re: Enhancing iterator objects with map, filter, reduce methods

In your comprehension example, I'm fairly certain the filtering should be on the post incremented remainder [ x+1 for x in [1,2,3] if (x+1) % 2 == 0] I think that is the downside of the comprehension, having to repeat that twice. Maybe you can get around it with := ?? I'm stuck on 3.7 so I don't know for sure.

Matt D wrote:
In your comprehension example, I'm fairly certain the filtering should be on the post incremented remainder [ x+1 for x in [1,2,3] if (x+1) % 2 == 0]
how about [ sum for num in [1,2,3] if ((sum := num + 1) %2 == 0]

Matt D wrote:
In your comprehension example, I'm fairly certain the filtering should be on the post incremented remainder [ x+1 for x in [1,2,3] if (x+1) % 2 == 0]
how about [ sum for num in [1,2,3] if ((sum := num + 1) %2 == 0]
participants (2)
-
Matt D
-
TobiasHT