On this page
all
Prev: aiter | Up: __builtins__ | Next: anext
Rel: any, enumerate, filter, iter, aiter
Ref: docs.python.org — all
Tags: #public #python3 #builtins
Import & Availability
# Built-in (available globally without import)
from builtins import all
Overview & Signature
all(iterable, /)
Return True if bool(x) is True for all values x in the iterable.
Usage
assert all(x > 0 for x in [1, 2, 3]) is True
assert all([True, 0, True]) is False
assert all([]) is True # vacuous truth on empty iterables!
Gotchas
- Short-circuits on the first falsy item: Pass a generator expression rather than a list comprehension to avoid extra work.
all([])isTrue: Checkbool(items) and all(...)if an empty sequence should fail.
REPL Inspect
help(all)
Linked from
- tuts/python3/__builtins__
- tuts/python3/__builtins__/__builtins__
- tuts/python3/__builtins__/aiter
- tuts/python3/__builtins__/anext
- tuts/python3/__builtins__/any
- tuts/python3/__builtins__/enumerate
- tuts/python3/__builtins__/filter
- tuts/python3/__builtins__/iter
- tuts/python3/__builtins__/len
- tuts/python3/__builtins__/map
- tuts/python3/__builtins__/next
- tuts/python3/__builtins__/reversed
- tuts/python3/__builtins__/sorted
- tuts/python3/__builtins__/zip
Related notes
- tuts/python3/__builtins__/__builtins__ Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/aiter Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/anext Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/any Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/enumerate Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/filter Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/iter Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__ links to this page; shared tags: #builtins
- tuts/python3/__builtins__/len links to this page; shared tags: #builtins
- tuts/python3/__builtins__/map links to this page; shared tags: #builtins