【发布时间】:2013-07-24 06:10:35
【问题描述】:
>>> l = list(range(10))
>>> l
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> if filter(lambda x: x > 10, l):
... print "foo"
... else: # the list will be empty, so bar will be printed
... print "bar"
...
bar
我想改用any(),但any() 只接受一个参数:可迭代。有没有更好的办法?
【问题讨论】:
标签: python python-2.7 functional-programming any filterfunction