def functionWithExplicitParameters(a, b, c): # The order of arguments in the function call will match the # order of the parameters in the function definition print 'functionWithExplicitParameters:', a, b, c def functionUsingAbritraryParameters(*arguments): # The order of the arguments in the function call will appear # here as a tuple print 'functionUsingAbritraryParameters:', for arg in arguments: print arg, print def functionUsingKeywords(**keywords): keys = sorted(keywords.keys()) for kw in keys: print kw, ':', keywords[kw] # An example from https://docs.python.org/2/tutorial/controlflow.html#keyword-arguments # that uses explicit, arbitrary, and keyword arguments def cheeseshop(kind, *arguments, **keywords): print "-- Do you have any", kind, "?" print "-- I'm sorry, we're all out of", kind for arg in arguments: print arg print "-" * 40 keys = sorted(keywords.keys()) for kw in keys: print kw, ":", keywords[kw] if __name__ == '__main__': # call each of the functions functionWithExplicitParameters('fred', 'mary', 'louise') print "-" * 40 # print a dashed line 40 characters long functionUsingAbritraryParameters('fred', 'mary', 'louise') print "-" * 40 # print a dashed line 40 characters long and a newline functionUsingKeywords(name='horace', dog='Ralf', age=21) print "-" * 40 # print a dashed line 40 characters long and a newline # from https://docs.python.org/2/tutorial/controlflow.html#keyword-arguments cheeseshop("Limburger", "It's very runny, sir.", "It's really very, VERY runny, sir.", "here is another arbitrary argument", shopkeeper='Michael Palin', client="John Cleese", sketch="Cheese Shop Sketch")