obj in list and list ids the same
Amit Patel
amitp at Xenon.Stanford.EDU
Tue Dec 28 22:04:56 EST 1999
<rdudfield at my-deja.com> wrote:
| Hello,
|
| I've got a problem where a list has the same id as a object instance in that
| same list. This is as returned by id().
|
| Is this ever supposed to happen? I just thought this was odd.
It is odd.
Here's how it could happen:
>>> a = []
>>> a.append(a)
>>> id(a)
135070976
>>> id(a[0])
135070976
Let's try printing this:
>>> a
[[...]]
The list has a pointer to itself. I'm not sure if this is the same
problem you're seeing, but you might poke around to see if you're
accidentally using some list instead of some list[some index].
- Amit
More information about the Python-list
mailing list