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/2003-October/039578.html below:

[Python-Dev] product()

[Python-Dev] product() [Python-Dev] product()Jeremy Fincher fincher.8 at osu.edu
Sun Oct 26 13:10:27 EST 2003
On Sunday 26 October 2003 09:39 am, Nick Coghlan wrote:
>  >>> if all(pred(x) for x in values): pass       # alltrue
>  >>> if any(pred(x) for x in values): pass       # anytrue

Yeah, that does read nicely, which is why I think it's pretty common in FPLs.

>  >>> if any(not pred(x) for x in values): pass   # anyfalse

I've always expressed this as:

if not all(pred(x) for x in values): pass

>  >>> if all(not pred(x) for x in values): pass   # allfalse

And this as:

if not any(pred(x) for x in values): pass

It's slightly more efficient (only one negation), and it seems to maintain 
better the pseudocode-like aspect that we so much adore in Python :)

Jeremy

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