This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author htnieman
Recipients htnieman
Date 2011-04-19.08:20:50
SpamBayes Score 5.6280605e-08
Marked as misclassified No
Message-id <>
I run this script with option --help
import argparse
parser = argparse.ArgumentParser()
parser.add_argument ('--from-itm', dest="from_itm",action="store",default=None,help ="Source ITM file", metavar="ITMFILENAME")
parser.add_argument ("--from-fbm-sigtab",dest="from_sigtab",action="store",default=None,help="Source signal FB", metavar=" [LIB,]FBNAME")
parser.add_argument ("--c",dest="f",metavar="x]d")
args = parser.parse_args()
and I get an assertion failure:
D:\temp> --help
Traceback (most recent call last):
  File "D:\temp\", line 6, in <module>
    args = parser.parse_args()
  File "C:\Python27\lib\", line 1678, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "C:\Python27\lib\", line 1710, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "C:\Python27\lib\", line 1916, in _parse_known_args
    start_index = consume_optional(start_index)
  File "C:\Python27\lib\", line 1856, in consume_optional
    take_action(action, args, option_string)
  File "C:\Python27\lib\", line 1784, in take_action
    action(self, namespace, argument_values, option_string)
  File "C:\Python27\lib\", line 993, in __call__
  File "C:\Python27\lib\", line 2303, in print_help
    self._print_message(self.format_help(), file)
  File "C:\Python27\lib\", line 2277, in format_help
    return formatter.format_help()
  File "C:\Python27\lib\", line 278, in format_help
    help = self._root_section.format_help()
  File "C:\Python27\lib\", line 208, in format_help
  File "C:\Python27\lib\", line 329, in _format_usage
    assert ' '.join(opt_parts) == opt_usage
It must be the combination of several argument lines because when I 
comment out one of the add_arguments, it works.

Is this a bug or do I do things I shouln't?
If it is not allowed to use [] in metavars (what I wanted was metavar='[optional,]mantatory'), I' like to receive a readable error message.

With best regards
Hartmut Niemann
Date User Action Args
2011-04-19 08:20:52htniemansetrecipients: + htnieman
2011-04-19 08:20:52htniemansetmessageid: <>
2011-04-19 08:20:50htniemanlinkissue11874 messages
2011-04-19 08:20:50htniemancreate