There is an array of many various items (functions, object properties, values), for example:
lst = [
1,
a(),
obj.prop,
...
z()
]
I'd like to check all of values are True, so I use all()
:
all(lst)
But in this case all values of list are calculated at the moment list created.
The aim is not to calculate all values on list initialization, but calculate it "on the fly" and stop iterate (and calculate) on first False item in list. So one solution is to yield every value from generator:
def gen():
yield 1
yield a()
yield obj.prop
...
yield z()
But it is not dry code and looks ugly with repeated yield keyword. Is there any another, more beautiful, solution?