list.append problem?
Julian Tibble
chasm at galileo.rift
Tue Oct 2 14:16:18 EDT 2001
In article <trjcuqh5bdrs89 at corp.supernews.com>, Bob Parnes wrote:
>As another newcomer I discovered this on my own. What is confusing, I
>think, is that it seems to apply only to empty objects. For example
Ummmm, no.
>>>> a = b = [1, 2. 3]
>>>> a = [4, 5, 6]
Erm, you're not changing the contents of `a' here - you're making `a'
reference a different list entirely!
>In this case a and b are not bound to the same object. It seems to me that
>python treats empty objects differently from assigned objects. Or something
>like that, I'm probably not articulating it well.
Empty objects are not treated any differently than objects with contents:
>>> a = b = [1, 2, 3]
>>> b.append(4)
>>> a
[1, 2, 3, 4]
Julian
More information about the Python-list
mailing list