[stdlib-sig] Pyopt - command-line options that are alot easier than optparse
holger at merlinux.eu
Thu Sep 10 12:03:00 CEST 2009
On Thu, Sep 10, 2009 at 03:38 +0300, Yuvgoog Greenle wrote:
> Hi stdlib-sig,
> I wanted to ease exposing functions to the command-line using python 3
> features and the result is http://code.google.com/p/pyopt/
> <http://code.google.com/p/pyopt/>I think this could be good stuff for the
> standard library and I'm not sure how to go about it, should I work on
> integrating with optparse/optik (is that project still active?) or should
> this be a separate module?
> This is an example usage of pyopt.0.71:
> import pyopt
> expose = pyopt.Exposer()
> def possy(archer:str, boulder:float, magic:int=42):
> """Shows an example positional command-line function.
> archer - is a str
> boulder - should be a float
> magic - a number that is magical"""
> print(repr(archer), repr(boulder), repr(magic))
> if __name__ == "__main__":
interesting! If i were you i'd not bother with the standard
library but just publish the module and project on PyPI.
With two other packages already in it si hard to add
a third and making an extension to optparse is probably
btw, myself i'd only use it if it also works <3.0.
A similar idea i had was this, btw:
def main(archer=str, boulder=float, magic=42):
which would wrap a parser around the function
and otherwise work like your example. This can
easily work down to Python2.3.
More information about the stdlib-sig