A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-March/052040.html below:

[Python-Dev] Adding any() and all()

[Python-Dev] Adding any() and all()Nick Coghlan ncoghlan at iinet.net.au
Fri Mar 11 15:43:10 CET 2005
Peter Astrand wrote:
> Personally, I think Python has too many builtins already.

A suggestion was made on c.l.p a while back to have a specific module dedicated 
to reductive operations. That is, just as itertools is oriented towards 
manipulating iterables and creating iterators, this module would be oriented 
towards consuming iterators in a reductive fashion.

product(), anytrue() and alltrue() were obvious candidates for inclusion ([1]).

The combination of explicit for loops and a standard toolkit of reductive 
operations was designed to eliminate the need for reduce() ([2]).

Cheers,
Nick.

[1] While any()/all() read well in the context of an if statement, I think 
anytrue()/alltrue() better convey the reductive nature of the operations, read 
nearly as well in the if context, and read significantly better when isolated 
from the if context (e.g. assigned to a variable). I also think the names are 
less likely to collide with existing variable names.

[2] I'm firmly in Guido's camp on this one - whenever I encounter code that uses 
reduce(), I have to rewrite it (either mentally or literally) to use a for loop 
before I can understand it. Getting rid of the function would benefit me because 
I would no longer have to waste time figuring out what such code was doing - it 
would already be an explicit loop, or it would be using one of the standard 
reductive operations.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4