any() and all() on empty list?

Duncan Booth duncan.booth at invalid.invalid
Thu Mar 30 09:27:52 CEST 2006

Ron Adam wrote:

> Where we are assembling widgets in a manufacturing plant. Where we don't 
> want to go to the next step until *all* the sub parts are present.
> if all(part.status == 'present' for part in unit):
>      do_release()
> Oops!  Some empty bins showed up at the next assembly station. ;-)

I don't see the problem. You only get an empty bin if there is some part 
assembled from no sub-parts, in which case you wanted an empty bin.

More information about the Python-list mailing list