My guess is that Python sees the space and decides it isn't a short string so it doesn't get interned. I got the expected results when I used 'green_ideas' instead of 'green ideas'. -Drew
On Wed, Jul 1, 2009 at 6:43 PM, Marc Tompkins<[email protected]> wrote: > On Wed, Jul 1, 2009 at 5:29 PM, Robert Berman <[email protected]> wrote: >> >> > >>> n = "colourless" >> > >>> o = "colourless" >> > >>> n == o >> > True >> > >>> n is o >> > True >> > >>> p = "green ideas" >> > >>> q = "green ideas" >> > >>> p == q >> > True >> > >>> p is q >> > False >> > >> > Why the difference? >> >> The string p is equal to the string q. The object p is not the object q. >> >> Robert > > Yes, but did you read his first example? That one has me scratching my > head. > -- > www.fsrtechnologies.com > > _______________________________________________ > Tutor maillist - [email protected] > http://mail.python.org/mailman/listinfo/tutor > > _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
