Alan Gauld wrote:
> "Yasar Arabaci" <yasar11...@gmail.com> wrote
> 
>> >>> a=["a"]
>> >>> b=[a]
>> >>> a.append("c")
>> >>> b
>> [['a', 'c']]
>>
>> Apperantly, I can change something (which is mutable) inside  a list
>> without even touching the list itself :)
> 
> But the point is that you *are* touching the list.
> In this case you have two names referring to the same list.
> You can modify that list (because it is mutable) via either name, it
> makes no difference because they both refer to the same list.
> 
> So a.append() is exactly the same operation as b.append()

In this case it is not exactly the same since he said b = [a],
not b = a. So b.append('c') would produce [['a'], 'c'].

Best,
Marcin
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to