Skip to content

Commit 7dc02cf

Browse files
author
Vinícius Vargas
committed
remove mutable default argument in prototype __deepcopy__ method
1 parent 5932a6f commit 7dc02cf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Prototype/Conceptual/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __copy__(self):
4242

4343
return new
4444

45-
def __deepcopy__(self, memo={}):
45+
def __deepcopy__(self, memo=None):
4646
"""
4747
Create a deep copy. This method will be called whenever someone calls
4848
`copy.deepcopy` with this object and the returned value is returned as
@@ -54,6 +54,8 @@ def __deepcopy__(self, memo={}):
5454
to all the `deepcopy` calls you make in the `__deepcopy__` implementation
5555
to prevent infinite recursions.
5656
"""
57+
if memo is None:
58+
memo = {}
5759

5860
# First, let's create copies of the nested objects.
5961
some_list_of_objects = copy.deepcopy(self.some_list_of_objects, memo)

0 commit comments

Comments
 (0)