Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Why does Python behave like this?

Name: Anonymous 2014-02-27 11:42

>>> a = "Early morning"
>>> a is "Early morning"
False
>>> a = "Early_morning"
>>> a is "Early_morning"
True

Name: Anonymous 2014-02-27 14:20

Implementation can cache string objects if it chooses so. If you really need to compare strings with is (and you don't) do it like this:

>>> a = "Early morning"
>>> a is "Early morning"
False
>>> import sys
>>> sys.intern("Early morning") is a
True

Name: Anonymous 2014-02-27 15:32

>>5
sys.intern(
HORRID BLOAT

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List