[pyar] mini problema con argparse
Martín Gaitán
gaitan en gmail.com
Mar Mayo 24 02:33:32 ART 2011
2011/5/24 Juan BC <jbc.develop en gmail.com>:
> estoy migrando algunas cosas de optparse a argparse... y tengo siguiente
> código
>
> #===============================================================
> #coso.py
> import argparse
>
> parser = argparse.ArgumentParser()
> parser.add_argument("command",
> action="store",
> type=str,
> metavar="<COMMAND>")
> parser.add_argument("options",
> action="store",
> nargs='*',
> type=str,
> default=[],
> metavar="<OPTION, [OPTION_2, ..., OPTION_N]>")
>
> parser.parse_args()
> #===============================================================
>
> al ejecutarlo me tira la siguiente exception
>
> #===============================================================
> File "coso.py", line 15, in <module>
> parser.parse_args()
> File "/usr/lib/pymodules/python2.6/argparse.py", line 1698, in parse_args
> args, argv = self.parse_known_args(args, namespace)
> File "/usr/lib/pymodules/python2.6/argparse.py", line 1730, in
> parse_known_args
> return self._parse_known_args(args, namespace)
> File "/usr/lib/pymodules/python2.6/argparse.py", line 1943, in
> _parse_known_args
> self.error(_('too few arguments'))
> File "/usr/lib/pymodules/python2.6/argparse.py", line 2352, in error
> self.print_usage(_sys.stderr)
> File "/usr/lib/pymodules/python2.6/argparse.py", line 2314, in print_usage
> self._print_message(self.format_usage(), file)
> File "/usr/lib/pymodules/python2.6/argparse.py", line 2270, in format_usage
> return formatter.format_help()
> File "/usr/lib/pymodules/python2.6/argparse.py", line 314, in format_help
> help = self._root_section.format_help()
> File "/usr/lib/pymodules/python2.6/argparse.py", line 244, in format_help
> func(*args)
> File "/usr/lib/pymodules/python2.6/argparse.py", line 366, in _format_usage
> assert ' '.join(pos_parts) == pos_usage
> AssertionError
> #===============================================================
>
> LA verdad que muy no tengo bien idea por que sucede y me la pase leyendo la
> documentación(seguro que se me paso algo por arriba)
No tengo una respuesta puntual a tu pregunta, pero te recomiendo plac
[1] Documentación (y me saco el sombrero/gorrito de lana) [2]
[1] http://pypi.python.org/pypi/plac
[2] http://micheles.googlecode.com/hg/plac/doc/plac.html
More information about the pyar
mailing list