is
when comparing type
of two objects 51 """Loads data from a JSON"""
52 lg.info('Reading data from data.json')
53 for key, value in json.items():
54 if type(value) == dict and key in data: 55 data[key] = implement(value, data[key])
56 else:
57 data[key] = value
It is recommended to use identity test
( is
) instead of equality test ( ==
) when you need to compare types of two objects.
if type(x) == str:
print(x)
if type(x) is str:
print(x)
# Alternatively,
if isinstance(x, str):
print(x)