从docs,all
相当于:
def all(iterable):
for element in iterable:
if not element:
return False
return True
那为什么我会得到这个输出:
# expecting: False
$ python -c "print( all( (isinstance('foo', int), int('foo')) ) )"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ValueError: invalid literal for int() with base 10: 'foo'
什么时候:
# expecting: False
$ python -c "print( isinstance('foo', int) )"
False