Reading `__defaults__` After Mutation
Continuing with the two functions from before:
def accumulate(x, bucket=[]):
bucket.append(x)
return bucket
def replace(x, bucket=[]):
bucket = bucket + [x]
return bucket
accumulate(1)
accumulate(2)
replace(1)
replace(2)
print(accumulate.__defaults__)
print(replace.__defaults__)
What do the two print calls show?
Sign in to answer questions and track your progress
Sign In