= True
cache
if cache:
print('data will be cached')
data will be cached
A boolean
value takes one of True
or False
, which are built-in values
check if cache
is True, using if
statement
if
statement using a bool evaluates to True or False
= True
cache
if cache:
print('data will be cached')
data will be cached
print(type(cache))
<class 'bool'>
Booleans are frequently used in if/then
statements.
We’ll cover these later.
= True
cache = False
oome
if cache or oome:
print('condition met!')
else:
print("No dice.")
AND statements will short circuit if an early condition fails.
if oome and cache:
print('condition met!')
In this case, since oome is False, the check on cache never happens.