On this page
True
Prev: NotImplemented | Up: __builtins__ | Next: abs
Rel: False, None, Ellipsis, NotImplemented, copyright
Ref: docs.python.org — True
Tags: #public #python3 #builtins
Import & Availability
# Built-in (available globally without import)
from builtins import True
Overview & Signature
True -> bool
Returns True when the argument is true, False otherwise.
Usage
assert True == 1 and isinstance(True, int)
assert sum([True, False, True]) == 2 # handy for counting truthy conditions
Gotchas
- Subclass of
int:True == 1isTrue, so checkisinstance(x, bool)beforeisinstance(x, int)when type-dispatching.
REPL Inspect
help(True)
Linked from
- tuts/python3/__builtins__
- tuts/python3/__builtins__/__builtins__
- tuts/python3/__builtins__/abs
- tuts/python3/__builtins__/copyright
- tuts/python3/__builtins__/credits
- tuts/python3/__builtins__/Ellipsis
- tuts/python3/__builtins__/exit
- tuts/python3/__builtins__/False
- tuts/python3/__builtins__/help
- tuts/python3/__builtins__/license
- tuts/python3/__builtins__/None
- tuts/python3/__builtins__/NotImplemented
- tuts/python3/__builtins__/quit
Related notes
- tuts/python3/__builtins__/__builtins__ Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/abs Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/copyright Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/Ellipsis Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/False Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/None Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/NotImplemented Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__ links to this page; shared tags: #builtins
- tuts/python3/__builtins__/credits links to this page; shared tags: #builtins
- tuts/python3/__builtins__/exit links to this page; shared tags: #builtins