def donot_use_mutable_default_param(idx=0, ids=None): if ids is None: ids = [] ids.append(idx) print(idx) print(ids) donot_use_mutable_default_param(idx=1) donot_use_mutable_default_param(idx=2)