Message249765
What is actually happening is that the *contents* of the list are copied, but the list itself is not. This is a consequence of the definition in terms of +. So, yes, that is a shallow copy, but not quite in the sense that mylist.copy() is a shallow copy, since the references to the contents of s get appended to the list being constructed by *, not a new list that is a "copy" of s.
You are correct that "s is only referenced" is not really accurate. But how about "Note that the contents of the *s* object are not copied, they are referenced multiple times". I think that highlights the source of the confusion: that the *contents* are not copied. |
|
Date |
User |
Action |
Args |
2015-09-04 14:23:13 | r.david.murray | set | recipients:
+ r.david.murray, georg.brandl, steven.daprano, docs@python, martin.panter, matheus.v.portela, Abraham.Smith |
2015-09-04 14:23:13 | r.david.murray | set | messageid: <1441376593.04.0.101670870642.issue23406@psf.upfronthosting.co.za> |
2015-09-04 14:23:13 | r.david.murray | link | issue23406 messages |
2015-09-04 14:23:12 | r.david.murray | create | |
|