On Wed, Apr 11, 2018 at 1:41 PM, Steven D'Aprano email@example.com wrote:
Personally, I still think the best approach here is a combination of itertools.accumulate, and the proposed name-binding as an expression feature:
total = 0 running_totals = [(total := total + x) for x in values] # alternative syntax running_totals = [(total + x as total) for x in values]
If you don't like the dependency on an external variable (or if that turns out not to be practical) then we could have:
running_totals = [(total := total + x) for total in  for x in values]
Linking this to the PEP 572 thread, this is an open question now:
Anyone who's interested in (or intrigued by) this potential syntax is very much welcome to hop over to the PEP 572 threads and join in.