Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4fbd03c

Browse files
authored
Merge pull requestRefactoringGuru#9 from santunioni/master
remove mutable default argument in prototype __deepcopy__ method
2 parents5932a6f +7dc02cf commit4fbd03c

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
returnnew
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+
ifmemoisNone:
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)

[8]ページ先頭

©2009-2025 Movatter.jp