Difference between mutation, rebinding, copying value, and assignment operator

后端 未结 4 449
小蘑菇
小蘑菇 2020-12-03 06:06
#!/usr/bin/env python3.2

def f1(a, l=[]):
    l.append(a)
    return(l)

print(f1(1))
print(f1(1))
print(f1(1))

def f2(a, b=1):
    b = b + 1
    return(a+b)

prin         


        
4条回答
  •  情深已故
    2020-12-03 06:19

    In f1 you are storing the value in an array or better yet in Python a list where as in f2 your operating on the values passed. Thats my interpretation on it. I may be wrong

提交回复
热议问题