J
John O'Hagan
Hi,
I was getting some surprising false positives as a result of not expecting
this:
all(element in item for item in iterable)
to return True when 'iterable' is empty.
I guess it goes into hairy Boolean territory trying to decide if an element is
in an item that doesn't exist (if that's what's happening), but I would have
thought not. It seems inconsistent with the behaviour of
any(element in item for item in iterable)
which returns False when 'iterable' is empty.
Sorry if this has come up before, but 'any' and 'all' make for fruitless
googling!
Any light to be shed?
Regards,
John
I was getting some surprising false positives as a result of not expecting
this:
all(element in item for item in iterable)
to return True when 'iterable' is empty.
I guess it goes into hairy Boolean territory trying to decide if an element is
in an item that doesn't exist (if that's what's happening), but I would have
thought not. It seems inconsistent with the behaviour of
any(element in item for item in iterable)
which returns False when 'iterable' is empty.
Sorry if this has come up before, but 'any' and 'all' make for fruitless
googling!
Any light to be shed?
Regards,
John