On 4/19/2012 7:20 AM, Alek Storm wrote:

Why not use list comprehension syntax?

For 3.x, that should be shortened to "Why not use comprehension syntax?", where comprehensions by default become generator expressions.

These:
> Map: [val+1 for val in some_list]
> Filter: [val for val in some_list if val > 0]

become
> Map: (val+1 for val in some_list)
> Filter: (val for val in some_list if val > 0)

as map and filter produce iterators, just like comprehensions interpreted as generator expressions.

functions (reduce() was removed from 3.0 for reasons I will never
understand).

The signature of Python's reduce is defective* because it combines two versions of reduce (2 and 3 arg forms) into one function in a way that makes it confusing and hard to use and therefore less used than it might be otherwise. So it was moved (not removed) to the functools module.

* One consistent signature that people could remember would be
reduce3(update(current,next), initial_current, source_of_nexts)

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to