is
when comparing type
of two objects23 map(
24 lambda entry: entry[1],
25 filter(
26 lambda entry: not entry[0].startswith('__') and type(entry[1]) == str,27 NotificationType.__dict__.items(),
28 ),
29 )
is
when comparing type
of two objects 50 map(
51 lambda entry: entry[1],
52 filter(
53 lambda entry: not entry[0].startswith('__') and type(entry[1]) == str, 54 MailType.__dict__.items(),
55 ),
56 )
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)