|
|
|
|
|
by Confusion
6203 days ago
|
|
Just because you already happen to have a certain function at your disposal doesn't mean your language is suddenly superior. def partition(n, step, coll):
for i in range(0, len(coll), step):
yield coll[i:i+n]
allows weekly = [sum(week) for week in partition(7, 7, daily)]
Using Python's map() function you can even do map(sum, partition(7, 7, daily))
making it exactly the same as your example. And no, I probably haven't written more Python than you in my life. |
|
> That's pretty unreadable for someone who doesn't know clojure.
The real reason for commenting was to show that it is readable and yes, providing the "readable" Python equivalent.
There are two points - firstly, Clojure is (or is becoming?) a lazy language and the list type is different, so no they are definitely not exactly the same.
This brings us to a broader point in that even if you were to have laziness in Python it still wouldn't matter because I'm not the only coder in the world and there are a lot of Pythonists like the author of the article who do it the Pythonic way, which as already hinted, I think is just braindead.