Use None as default parameter
examples/advanced/none_as_default_parameter.py
def f(a, b = None): if b == None: b = [] b.append(a) return b print(f(1)) print(f(2)) print(f(3))
[1] [2] [3]
def f(a, b = None): if b == None: b = [] b.append(a) return b print(f(1)) print(f(2)) print(f(3))
[1] [2] [3]