Examples#
Default Behavior#
def f(x=[]):
x.append(2)
return x
>>> a = f()
>>> a
[2]
>>> f()
>>> a
[2, 2]
Altered Behavior#
from stabledefaults import stabledefaults
@stabledefaults()
def f(x=[]):
x.append(2)
return x
>>> a = f()
>>> a
[2]
>>> f()
>>> a
[2]