>>> 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
Chciałbym użyć zamiast tego any()
, ale any()
przyjmuje tylko jeden argument: iterowalny. Czy istnieje lepszy sposób?Jak uzyskać dowolne() z pythona z niestandardowym predykatem?