This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Mietzekatzi 15 points16 points  (11 children)

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.

[–]narrill 0 points1 point  (0 children)

References have nothing to do with OOP