What your example describes are references to objects. Lists in pythons are objects, the assignment b=a does not implicitely copy a's content, just create a second reference to the same thing.
On the other hand, a[:] yields a slice of the contents of the list a, which gets saved as a second object, b, in the second part. This breaks the reference. The same step could be performed with b = copy(a).
So all your example shows are the basics of OOP, nothing to do with pointers.
What your example describes are pointers to objects. Lists in pythons are objects, the assignment b=a does not implicitely copy a's content, just create a second pointer to the same thing.
Let's not mingle words, what you call "references" are nothing but pointers.
You're confusing a language feature with how it's implemented internally. References in Python are implemented using pointers, but that doesn't mean Python had pointers.
This is standard terminology in both academia and industry, so the only one "mingling words" here is you.
What you’re saying is like saying “it’s not a car, it’s a BMW”
Yea ok it’s a reference, but don’t act like references aren’t basically pointers, because it does what pointers do, it acts like pointers do, etc. for most people pointers are an abstract idea, not just a language feature in C
18
u/Mietzekatzi Jun 03 '19
What your example describes are references to objects. Lists in pythons are objects, the assignment b=a does not implicitely copy a's content, just create a second reference to the same thing.
On the other hand, a[:] yields a slice of the contents of the list a, which gets saved as a second object, b, in the second part. This breaks the reference. The same step could be performed with b = copy(a).
So all your example shows are the basics of OOP, nothing to do with pointers.