filmov
tv
Shallow Copy In Python : DON'T MAKE THIS MISTAKE!
Показать описание
Python slices are a shallow copy. That means that if you have an object in a list, and you make a slice of that list. If you modify that object in either list then it will affect both lists.
This doesn't apply to basic types like integers or floats, but it would apply to lists, dictionaries, tuples, or custom classes.
So be aware that the list has a reference to the object, so you don't accidently make changes you don't intend to.
This doesn't apply to basic types like integers or floats, but it would apply to lists, dictionaries, tuples, or custom classes.
So be aware that the list has a reference to the object, so you don't accidently make changes you don't intend to.