by versteegen · 3y ago · 0 comments
accum = initial
series = [accum := bifun(accum, value) for value in seq]
# result = series[-1]
To be honest, this is the first time I've used the walrus operator.(Seriously, I like that.)
x = 0
deque((x := x + 1 for _ in range(10)), maxlen=0)
print(x)
>> 10
Using deque to consume generators is an old trick documented in the itertools recipes: https://docs.python.org/3/library/itertools.html#itertools-r...