EdisonChendi
11/27/2016 - 8:25 AM

don't use mutable types as default parameters

don't use mutable types as default parameters

# 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]