Where's the documentation to support the following behavior...
Emile van Sebille
emile at fenx.com
Tue Mar 17 20:25:44 EDT 2009
grocery_stocker wrote:
> On Mar 17, 3:22 pm, Emile van Sebille <em... at fenx.com> wrote:
>> grocery_stocker wrote:
>>> It seems like id(list[<some value>]) == id(<some value>).
>> It might seem that way, but test with other than single-character
>> strings, eg lists like [7],[8],[9] and try again.
> I still get the same thing...
Well, yes -- because you're still testing the same things. I meant of
course to test other things, like lists as in:
>>> for ii in [[7],[7],[8],[8],[9],[9]]: id(ii)
...
16607992
16608952
16609032
16608992
16608832
16608872
>>>
What you're testing is the content of the list elements, more like:
>>> for ii in [[7],[7],[8],[8],[9],[9]]: id(ii[0])
...
15424016
15424016
15424004
15424004
15423992
15423992
>>>
And as you've heard, interning is at the root of the apparent sameness..
Emile
More information about the Python-list
mailing list