[Tutor] When are strings interned?

Angus Rodgers angusr at bigfoot.com
Fri Jul 3 15:43:21 CEST 2009

This is partly a test to see if I can reply in the correct format
to a message in the tutor list (which I receive in digest format).

>Date: Thu, 02 Jul 2009 20:39:28 +1000
>From: Lie Ryan <lie.1296 at gmail.com>
>Angus Rodgers wrote:
>>>>> p = "green ideas"
>>>>> q = "green ideas"
>>>>> p == q
>> True
>>>>> p is q
>> False
>In this particular case, the reason is because "colourless" can be used
>as an identifier. 
>[...] Identifiers cannot contain spaces, that's why green ideas are
>not interned.

That is very clear, thanks.

Presumably a different optimisation is going on here:

>>> "green ideas" is "green ideas"

[Does it create confusion to quote a dialogue with the interpreter
in this way?  The >>> looks like an instance of e-mail quotation.]

>And... have I told you not to rely on this behavior? NEVER rely on this
>implementation details. Once you get bitten by it, you'll regret it.

Angus Rodgers

More information about the Tutor mailing list