Below is examples of passing arguments to python via regular argument assignment, and tuples and *tuples, and dictionaries and **dictionaries.

Here is my gist link for it: https://gist.github.com/anonymous/271d6160cdd90a482b40 (older)

Not covering all methods (for example didnt cover default values if argument is not passed http://lgiordani.com/blog/2015/02/11/default-arguments-in-python/#.VsBpuPIrKHs although default values for none stated argument can be achieved if *arg & *kargs are in the function prototype/definition), but most of them covered in the test script below
builds upon:
* http://pythontips.com/2013/08/04/args-and-kwargs-in-python-explained/
* http://stackoverflow.com/questions/9539921/python-function-with-optional-arguments
* and https://gist.github.com/c0ldlimit/4091273 (added test cases to this one)

Study the output and play around with the script to get better understanding
I ran it like this “python test.py
Im using python 2.7.3

Test Python Script: test.py

Output:

The end

Leave a Reply

Your email address will not be published. Required fields are marked *