New submission from Lene Preuss <lene.pre...@gmail.com>:
Obligatory apologies if this has been reported before, I could not find it. It is similar to but different from https://bugs.python.org/issue9334. >>> from argparse import ArgumentParser >>> p = ArgumentParser() >>> p.add_argument('-d') _StoreAction(option_strings=['-d'], dest='d', nargs=None, const=None, default=None, type=None, choices=None, help=None, metavar=None) >>> p.parse_args(['-d', '12']) Namespace(d='12') >>> p.parse_args(['-d', '1,2']) Namespace(d='1,2') >>> p.parse_args(['-d', '-12']) Namespace(d='-12') >>> p.parse_args(['-d', '-1,2']) usage: [-h] [-d D] : error: argument -d: expected one argument As suggested in issue 9334, passing the argument with an equals sign works: >>> p.parse_args(['-d=-1,2']) Namespace(d='-1,2') But I don't think that this is the intended behavior. ---------- messages: 328299 nosy: lene priority: normal severity: normal status: open title: argparse.ArgumentParser fails on arguments with leading dash and comma type: behavior versions: Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35049> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com