That doesn't feel like the aim of the walrus. Also, you got functions in itertools to do accumulation. There should be only one obvious way to do it, right?
-
-
-
accumulate() is fine for summation but awkward otherwise. Contrast: cashflows = [1000, -90, -90, -90, -90] list(accumulate(cashflows, lambda bal, pmt: bal*1.05 + pmt)) With: bal = 0.0; [(bal := bal*1.05 + pmt) for pmt in cashflows]
Kraj razgovora
Novi razgovor -
-
-
-
FWIW, positive_numbers() already exists in the itertools module. There's no need to write your own. >>> from itertools import count >>> it = count(start=1) >>> next(it) 1 >>> next(it) 2 >>> next(it) 3
- Još 1 odgovor
Novi razgovor -
-
-
Given what we know about how to write reliable programs we can easily reason about, features which encourage mutation seem like such a retrograde step.
- Još 9 drugih odgovora
Novi razgovor -
-
-
I can only hope you are joking, but it might not be obvious to a new reader. For the record, this construction is the worst Python idea I've ever seen: a complete failure on comprehension.
Hvala. Twitter će to iskoristiti za poboljšanje vaše vremenske crte. PoništiPoništi
-
-
-
that's horrifying
- Još 1 odgovor
Novi razgovor -
-
-
You just did!
Hvala. Twitter će to iskoristiti za poboljšanje vaše vremenske crte. PoništiPoništi
-
Čini se da učitavanje traje već neko vrijeme.
Twitter je možda preopterećen ili ima kratkotrajnih poteškoća u radu. Pokušajte ponovno ili potražite dodatne informacije u odjeljku Status Twittera.