Getting references to obect instances into a list

Timothy Grant timothy.grant at gmail.com
Wed Aug 27 18:15:18 CEST 2008


On Wed, Aug 27, 2008 at 8:32 AM, parent.eric.3 at gmail.com
<parent.eric.3 at gmail.com> wrote:
> Thanks for your reply Simon.
>
> I will read the article you told me to but first, please, have a look
> at this snippet:
>
>>>> m = [2,3,4]
>>>> p = ['a','b','c']
>>>> q = [m,p]
>>>> q
> [[2, 3, 4, 'a', 'b', 'c'], ['a', 'b', 'c']]
>>>> del p
>>>> q
> [[2, 3, 4, 'a', 'b', 'c'], ['a', 'b', 'c']]
>>>>
>
>
> How come q is not updated after I deleted p?
>
> This is my point.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Because the list still has a reference to the object formerly known as p.

-- 
Stand Fast,
tjg. [Timothy Grant]



More information about the Python-list mailing list