Thursday, October 27, 2016

Python command line arguments

I needed to be able to pass an argument into my program to allow it to run in two different ways. The syntax of the constructor that I'd simply copied from something else a long time ago is weird. It turns out that these are two different problems. Neither wasn't so bad once I dug into them.

To pass an argument into the program from the command line, just use c-like argc and argv:

http://www.cyberciti.biz/faq/python-command-line-arguments-argv-example/

The constructor is using a pythonic trick of indirectly referencing a function's argument list. It's nothing to do with the command line and isn't specific to constructors:

http://stackoverflow.com/questions/3394835/args-and-kwargs

https://mail.python.org/pipermail/tutor/2006-August/048394.html

https://pythonprogramming.net/styling-gui-bit-using-ttk/