On Sun, Nov 06, 2016 at 04:46:42PM -0200, Danilo J. S. Bellini wrote:

> 1.2. Sub-expressions in an expression might be on other statements (e.g.
> assignments, other functions).

Not in Python it can't be. Assignment is not an expression, you cannot 
say (x = 2) + 1.


> 2. The itertools.accumulate function signature is broken:
> 2.1. Its arguments are reversed when compared to other higher order
> functions like map, filter and reduce.

That's only "broken" if you think that we should be able to swap 
accumulate for map, filter and reduce. But that's not the case: 
accumulate is NOT broken because the API is not intended to be the same 
as map, filter and reduce. The API for accumulate is that the iterable 
is mandatory, but the function argument is *not*.


> 2.2. It lacks a "start" parameter, requiring more complexity to include it
> (nesting a itertools.chain or a "prepend" function call).

Then just create your own wrapper:

def accum(func, iterable, start=None):
    if start is not None:
        iterable = itertools.chain([start], iterable)
    return itertools.accumulate(iterable, func)



> 3. It's not about "adding complexity", it's the other way around:

No, I'm sorry, it does add complexity.

> 3.1. The proposal is about explicit recursion in a list comprehension (a
> way to access the previous output value/result, a.k.a.
> accumulator/state/memory).

List comprehensions are not intended for these sorts of complex 
calculations. Regular for-loops are easy to use and can be as general 
as you like.


> I'm not sure what you meant with "turn a sequence into a series", 

I think Stephen is referring to the mathematical concept of sequences 
and series.

A sequence is an ordered set of numbers obeying some rule, e.g.:

    [1, 2, 3, 4, 5]

while a series is the partial sums found by adding each term to the 
previous sum:

    [1, 3, 6, 10, 15]



-- 
Steve
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to