New submission from Ivan Kurnosov :
At this moment it's impossible to explain the behaviour of this script using
documentation.
Given it was explicitly coded to behave like that - it should be somehow noted
in the documentation, that as long as a `CliArgs.foo` field has a default value
set already - it won't be overwritten with a default argparse argument value.
```
import argparse
class CliArgs(object):
foo: str = 'not touched'
parser = argparse.ArgumentParser()
parser.add_argument('--foo', default='bar')
args = CliArgs()
parser.parse_args(namespace=args)
print(args.foo) # 'not touched'
print(parser.parse_args()) # 'bar'
```
--
assignee: docs@python
components: Documentation
messages: 356939
nosy: docs@python, zerkms
priority: normal
severity: normal
status: open
title: Document argparse behaviour when custom namespace object already has the
field set
___
Python tracker
<https://bugs.python.org/issue38843>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com