Keyword Arguments Demo : Function Keyword Arguments « Function « Python






Keyword Arguments Demo

Keyword Arguments Demo



# Functions can also be called using keyword arguments of the form 
# "keyword = value".

def parrot(voltage, state='state', action='action', type='type'):
    print "-- Action:", action,
    print "Vol", voltage 
    print "-- type:", type
    print "-- state", state


parrot(1000)
parrot(action = 'A', voltage = 1000000)
parrot('A', state = 'B')
parrot('A', 'B', 'C')


           
       








Related examples in the same category

1.Keyword arguments example.Keyword arguments example.
2.Keyword Parameters and DefaultsKeyword Parameters and Defaults