import string
print string.ascii_lowercase # abcdefghijklmnopqrstuvwxyz
print type(string.ascii_lowercase) # <type 'str'>
print string.ascii_lowercase is str # False
Shouldn’t it be True?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
isoperator compares the identity of two objects. This is what I believe it does behind the scenes:Actual strings are always going to have a different identity than the type
str, so this will always beFalse.Here is the most Pythonic way to test whether something is a string:
This will match both
strandunicodestrings.