[Python-ideas] custom predicate for all() & any()
INADA Naoki
songofacandy at gmail.com
Sat Mar 26 13:22:34 EDT 2016
>
>
> ## Example 1
>
> ages = [21, 13, 18]
> major = 18..__le__
>
> allowed = all(ages, major)
>
>
allowed = all(18 <= a for a in ages)
> ## Example 2
>
> people = [
> {"name": "Mike", "age": 42},
> {"name": "Josh", "age": 17}
> ]
> major = 18..__le__
>
> allowed = all(people, {"age": major})
>
allowed = all(18 <= p['age'] for p in people)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160326/d9559dd3/attachment-0001.html>
More information about the Python-ideas
mailing list