At 06:38 PM 3/10/05 -0800, Bill Janssen wrote: >Guido, > >I think there should be a PEP. For instance, I think I'd want them to be: > >def any(S): > for x in S: > if x: > return x > return S[-1] > >def all(S): > for x in S: > if not x: > return x > return S[-1] > >Or perhaps these should be called "first" and "last". More precisely (since "S" might be an iterator, or empty): def any(S): x = False for x in S: if x: break return x def all(S): x = True for x in S: if not x: break return x However, "first" and "last" don't make sense to me as names. First what? Last what? Actually, "any" and "all" don't make that much sense to me either. I find myself wanting to call them "or" and "and", or maybe "or_iter" and "and_iter". Or perhaps "until_false" or "until_true". Nah, the and/or names make more sense, as they exactly match the behavior of the corresponding logical operators, if you could call them as a function. At least, if they took *args anyway.
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