J
John O'Hagan
I find this surprising:
As an argument is provided, I didn't expect to see the default in there as
well. From the argparse docs: "the default value is used when the option
string was not present at the command line". While it doesn't say "_only_
when...", that's what I would have expected.
Is there a reason for this behaviour? Is there a way to do what I want, to get
a list of appended options _or_ a default list (apart from setting defaults
outside the parser, a good way to lose track of things)?
Thanks,
John
Namespace(test=['default', 'arg'])import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--test', action='append', default=['default']) [...]
parser.parse_args(['--test', 'arg'])
As an argument is provided, I didn't expect to see the default in there as
well. From the argparse docs: "the default value is used when the option
string was not present at the command line". While it doesn't say "_only_
when...", that's what I would have expected.
Is there a reason for this behaviour? Is there a way to do what I want, to get
a list of appended options _or_ a default list (apart from setting defaults
outside the parser, a good way to lose track of things)?
Thanks,
John