Created
November 27, 2016 08:25
-
-
Save EdisonChendi/d3a081b5852d15db8622d0e060ddb54c to your computer and use it in GitHub Desktop.
don't use mutable types as default parameters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=UTF-8 | |
def append(newitem, l = []): | |
l.append(newitem) | |
print(l) | |
print(append.func_defaults) # [] | |
append(10) | |
print(append.func_defaults) # [10] | |
append(20) | |
print(append.func_defaults) # [10, 20] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment