PEP 289: universal and existential operators
Alex Martelli
aleax at aleax.it
Wed Nov 5 09:51:56 EST 2003
Jeremy Fincher wrote:
...
> I think these names also read somewhat more clearly:
>
> # Check if someone is yelling:
> if all(str.isupper, line.split()):
> print "Must be a flamewar."
>
> and:
>
> # Check if someone yelled at all:
> if any(str.isupper, line.split()):
> print "Someone yelled."
I'm not sure what these calls are meant represent -- maybe an
interface similar to filter, i.e. a callable then a sequence?
The functions we're considering, whatever their names, would
in any case just take an iterator, so, e.g.:
if all(x.isupper() for x in line.split()):
and the like.
> I believe both these examples are more easily readable with "all" and
> "any" than they would be with "forall" and "exists."
I'll pass on that. Maybe. I think I still prefer alltrue and anytrue...
Alex
More information about the Python-list
mailing list