6 Antworten
+ 2
1. AttributeError: 'tuple' object has no attribute 'copy'.
2. list.copy() and dict.copy() are built-in functions for shallow copies. They're available since Python 3.4.
3. copy.copy() can also copy functions and classes.
0
Diego in point number 1, why we use tuple ? It is not mutable so using copy doesn't make sense ?
0
Kishalaya Saha please see this
0
Sorry, I'm not sure what you're confused about. It seems your questions have already been answered. Anyway, tuples might contain nested lists as elements, and those guys could be changed. So a deep copy might be necessary sometimes.