is
when comparing type
of two objects47 "or a comma-separated string" %
48 (option.name, option.type.__name__))
49
50 if type(value) == str and option.type != str:51 option.parse(value)
52 else:
53 option.set(value)
is
when comparing type
of two objects16 "or a comma-separated string" %
17 (option.name, option.type.__name__))
18
19 if type(os.environ[name]) == str and option.type != str:20 option.parse(os.environ[name])
21 else:
22 option.set(os.environ[name])
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)