[Pythonmac-SIG] string ids

Feat jf at ai.univ-paris8.fr
Mon Dec 29 20:46:37 CET 2008


At 11:30 -0500 29/12/08, David Hostetler wrote:
>The 'weird' results you were seeing when using 'is' were really just the python interpretor lifting up its skirts a bit and (inadvertantly perhaps) revealing when it had shared the memory storage for a string literal and when it hadn't.

Yes: thank you. Is there any way to predict whether the values are going to be shared or not? As a matter of fact, the ids are the same as long as I do not use any for statement with the values in a sequence, and when I use any, it will sometimes get them from the context and some other times it will make up new values.

I had hoped I could tell my students how to discriminate between the two cases. They are no C programmers yet, but they're fully aware of the difference between the eq() and equal() Lisp predicates, eq() being totally reliable as for pointers comparison.

-- 
Jym Feat ~ Paris FR 75018


More information about the Pythonmac-SIG mailing list