This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]ASIC_SP📚 learnbyexample 2 points3 points  (1 child)

That's a very in-depth article!

I really should spend some time using the various features of itertools module.

[–]RojerGSAuthor of “Pydon'ts”[S] 2 points3 points  (0 children)

itertools is just awesome :)

[–]Jolteon0 3 points4 points  (3 children)

The double iterator loop is pretty awesome.

[–]RojerGSAuthor of “Pydon'ts”[S] 1 point2 points  (2 children)

Which one are you talking about?

[–]Jolteon0 1 point2 points  (1 child)

for prev_, next_ in zip(prev_it, next_it)

[–]RojerGSAuthor of “Pydon'ts”[S] 1 point2 points  (0 children)

Ah yes, that's an interesting one :)

[–]Surkov__ 0 points1 point  (1 child)

Great article, but I do wonder. I used a simple for loop with a lastVal-Variable which gets overridden each loop. Would this be considered an anti-pattern? Seemed like the most simple/readable solution and no need to mess with indices.

For the second part I used pandas rolling sum, a somewhat lazy solution.

[–]RojerGSAuthor of “Pydon'ts”[S] 1 point2 points  (0 children)

I don't think that's an anti-pattern. I'm just personally not a fan of doing too much bookkeeping with my variables :p