The operator iscompares the identity of two objects. Here is what I think is happening behind the scenes:
id(string.ascii_lowercase) == id(str)
Actual strings will always have a different identity than the type str, so it will always be False.
Here is the most Pythonic way to check if something is a string:
isinstance(string.ascii_lowercase, basestring)
This will match the lines strand unicode.
source
share