Check if a default parameter value being used : Function Default Argument : Buildin Function PYTHON examples


PYTHON examples » Buildin Function » Function Default Argument »

 

Check if a default parameter value being used


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()


           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Buildin Function
» Function Default Argument