Problem with assigning variables of type List

Stas Z. stas at linux.isbeter.nl
Mon Aug 19 14:21:44 CEST 2002


On Mon, 19 Aug 2002 06:18:47 +0200, Abhishek Roy wrote:

> Hello,
>       It appears that,
> a = b = []
> is not the same as
> a=[]
> b=[]
> 
> because in the previous case a and b will refer to the same list eg,
>>>> b.append(23)
>>>> a
> [23]
> I am completely baffled by this. Can someone please explain?

a 'is a' b 'is a' []

You have a list and 'b' is the reference to that list.
Now 'a' is the reference to the reference 'b'.

Stas Z

-- 
We are Debian GNU/Linux...
     ...Resistance is measured in ohm's



More information about the Python-list mailing list