Mega Code Archive
Categories
/
Python
/
Function
Check if a default parameter value being used
def saver(x=None): if x is None: # no argument passed? x = [] # run code to make a new list x.append(1) # changes new list object print x saver([2]) saver() # doesn't grow here saver()