Khalid Al-Ghamdi wrote:
Hi All,
why is this so?
type('love')
"love" is str
False
The "is" operator tests for object identity. The line
"love" is str
tests whether the instance "love" is the same object as the class str.
Obviously that is not the case.
You might be thinking of an "i
You are comparing a string value with string class, so they can't be
compared. You can do:
>>> type("love") is str
True
>>>
so you compare types
2011/9/18 Khalid Al-Ghamdi
> Hi All,
>
> why is this so?
>
> >>> type('love')
>
> >>> "love" is str
> False
> >>>
>
> __
Hi All,
why is this so?
>>> type('love')
>>> "love" is str
False
>>>
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor