This is a small slice of a larger series I'm working on with the end goal of using mako, the khronos XML, and being python3 compatible with our generators. That series is over 100 patches already, and not even finished with the first step of using mako. I've sent this out to get some patches landed.
I've tested this with python 2.7 and 2.6. There is the catch that argparse became part of the standard library in 2.7, so 2.6 users will need to install argparse themselves, either with pip (pip install argparse) or via their package manager (most distros with python 2.6 package this). It seems to me that since python 2.6 was deprecated in octobor of 2013 it seem silly to support anything older (which would have a deprecation date in 2012 or before), and widens the gap between python 2 and python 3 both feature wise and syntax wise. Currently we use a mixture of getopt, optparse, and raw sys.argv munging to get command line arguments. Argparse is the de facto standard for python programs, it's clean, powerful, easy to understand, and it does everything in one place. It doesn't allow a usage() function to drift out of sync from the actual implementation, since the majority of the help message is auto generated, and the rest is part of the actual definition. This also moves to using the standard python idiom of a main() function called in the 'if __name__ == "__main__"' guard. This is an extremely common pattern, and it makes the code much cleaner. This is available on freedesktop.org: git://people.freedesktop.org/~dbaker/mesa submit/generator-argparse _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev