isinstance
calls PYL-R17011587 conversion : str or int
1588 Converted data role identifier.
1589 """
1590 if isinstance(data_role, int) or isinstance(data_role, float):1591 data_role = int(data_role)
1592 if data_role == 1:
1593 conversion = "TRAIN"
You can pass a tuple of types you want to check as the second argument to isinstance
.
If the object matches with any of the types, it will return True
else False
.
It is therefore recommended to merge multiple consecutive isinstance
calls into one. It is clearer and improves readability.
# Instead of
if isinstance(i, int) or isinstance(i, float):
print('A number')
# Do this
if isinstance(i, (int, float)):
print('A number')