What is a function parameter =[] for?
Ned Batchelder
ned at nedbatchelder.com
Thu Nov 19 19:36:17 EST 2015
On Thursday, November 19, 2015 at 7:28:44 PM UTC-5, Steven D'Aprano wrote:
> On Fri, 20 Nov 2015 05:50 am, BartC wrote:
>
>
> > I said that Python's "=" does a very shallow copy. And I stated that in
> > A=B, something of B must be copied into A.
> >
> > I (and probably others) would like to know why none of that is correct.
> > But I suspect I'm not wrong.
>
> Nothing of B is copied.
I think we are stuck in a simple terminology conflict here. There is something
of B copied. The name B refers to a value. In CPython, that reference is a
pointer. That pointer (the memory address) is copied from B to A.
Nothing of "B's value", that is, the object B is referring to, is copied. But
there is something about B (the pointer to its value) that is now also something
about A, because A also has that pointer.
--Ned.
More information about the Python-list
mailing list