|
Re: Python main() functions
|
Posted: Feb 13, 2008 3:43 AM
|
|
My favorite convention for writing main() can be found in anoption.py:
http://laurentszyster.be/blog/anoption/
>>> import anoption >>> def main ( a, b, c, d="", e=100, f=3.0, g=False, *args, **kwargs ): print a, b, c, d, e, f, g, args, kwargs >>> anoption.cli (main, [ "A", "B", "--extended", "C", "D", "-g=yes" "-f=12", ]) A B C D 100 12.0 True () {'extended': None} >>> print anoption.doc (main) a, b, c {-d="", -e=100, -f=3.0, -g=True, ...} [...]
|
|