From: Kenny Meyer on
On Jun 2, 12:37 am, Michele Simionato <michele.simion...(a)gmail.com>
wrote:
> I would like to announce to the world the first public release of
> plac:
>
>  http://pypi.python.org/pypi/plac
>
> Plac is a wrapper over argparse and works in all versions of
> Python starting from Python 2.3 up to Python 3.1.
>
> With blatant immodesty, plac claims to be the easiest to use command
> line arguments parser module in the Python world. Its goal is to
> reduce the
> learning curve of argparse from hours to minutes. It does so by
> removing the need to build a command line arguments parser by hand:
> actually it is smart enough to infer the parser from function
> annotations.
>
> Here is a simple example (in Python 3) to wet your appetite:
>
> $ cat example.py
> def main(arg: "required argument"):
>     "do something with arg"
>     print('Got %s' % arg)
>
> if __name__ == '__main__':
>     import plac; plac.call(main) # passes sys.argv[1:] to main
>
> $ python example.py -h
> usage: example.py [-h] arg
>
> do something with arg
>
> positional arguments:
>   arg         required argument
>
> optional arguments:
>   -h, --help  show this help message and exit
>
> $ python example.py
> usage: example.py [-h] arg
> example.py: error: too few arguments
>
> $  python example.py arg
> Got arg
>
> $  python example.py arg1 arg2
> usage: example.py [-h] arg
> example.py: error: unrecognized arguments: arg2
>
> You can find in the documentation a lot of other simple and not so
> simple
> examples:
>
>  http://micheles.googlecode.com/hg/plac/doc/plac.html
>
> Enjoy!
>
>              Michele Simionato
>
> P.S. answering an unspoken question: yes, we really needed yet
> another
> command line arguments parser! ;)

I like this approach to command-line argument parsing! Thanks for
sharing your work.