[Python-Dev] Small any/all enhancement
Valentino Volonghi aka Dialtone
dialtone at divmod.com
Tue Dec 27 21:45:01 CET 2005
I see that Python 2.5 will include a simple implementation of any/all.
What I would like to ask, before it's too late, is if it's possible to add an
optional test argument.
any(iterable, test=bool) and all(iterable, test=bool)
These would be the new proposed APIs. The usecase is to be able to extract
attributes from objects or simply to have arbitrary checks like:
import operator
any(some_objects, test=operator.attrgetter('some_attribute'))
or
def zerop(x):
return x==0
all(some_objects, zerop)
instead of preprocessing the generator with a generator expression before
passing it to any/all.
Thanks.
--
Valentino Volonghi aka Dialtone
Now Running MacOSX 10.4
Blog: http://vvolonghi.blogspot.com
http://weever.berlios.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-dev/attachments/20051227/e76dae5b/attachment.pgp
More information about the Python-Dev
mailing list