From 8c47ebfcebb622d10be1be89a6a93891ac3ce2bc Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Mon, 16 Sep 2024 20:59:47 -0700 Subject: [PATCH 1/5] Add additional clarification on defaults --- Doc/library/argparse.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index aa1341c8d4d4a8..5dffb4fe1f48e4 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -2123,7 +2123,10 @@ Parser defaults >>> parser.parse_args(['736']) Namespace(bar=42, baz='badger', foo=736) - Note that parser-level defaults always override argument-level defaults:: + Note that defaults can be set at both the parser level using :meth:`set_defaults` + and at the argument level using :meth:`add_argument`. If both are provided for the + same attribute, the order of setting these defaults determines which one takes + precedence. The last default set for an attribute is the one that is used: >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--foo', default='bar') From 8bf04ed1b5a06af8e68e6b3d8c9a29de1d17c87d Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Mon, 16 Sep 2024 21:01:05 -0700 Subject: [PATCH 2/5] update to use argument --- Doc/library/argparse.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 5dffb4fe1f48e4..791893aa11185d 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -2125,8 +2125,8 @@ Parser defaults Note that defaults can be set at both the parser level using :meth:`set_defaults` and at the argument level using :meth:`add_argument`. If both are provided for the - same attribute, the order of setting these defaults determines which one takes - precedence. The last default set for an attribute is the one that is used: + same argument, the order of setting these defaults determines which one takes + precedence. The last default set for an argument is the one that is used: >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--foo', default='bar') From 2232b8d1bbce88752a908b4c0a18df9aa58b921a Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Mon, 16 Sep 2024 21:16:53 -0700 Subject: [PATCH 3/5] appease linter --- Doc/library/argparse.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 791893aa11185d..606c82668ee8e0 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -2123,9 +2123,9 @@ Parser defaults >>> parser.parse_args(['736']) Namespace(bar=42, baz='badger', foo=736) - Note that defaults can be set at both the parser level using :meth:`set_defaults` + Note that defaults can be set at both the parser level using :meth:`set_defaults` and at the argument level using :meth:`add_argument`. If both are provided for the - same argument, the order of setting these defaults determines which one takes + same argument, the order of setting these defaults determines which one takes precedence. The last default set for an argument is the one that is used: >>> parser = argparse.ArgumentParser() From 3c649a79a1ba5efa7fe2353195d8eff076a0c2da Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Tue, 17 Sep 2024 08:10:39 -0700 Subject: [PATCH 4/5] add : --- Doc/library/argparse.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 606c82668ee8e0..751576e4ca8cd5 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -2126,7 +2126,7 @@ Parser defaults Note that defaults can be set at both the parser level using :meth:`set_defaults` and at the argument level using :meth:`add_argument`. If both are provided for the same argument, the order of setting these defaults determines which one takes - precedence. The last default set for an argument is the one that is used: + precedence. The last default set for an argument is the one that is used:: >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--foo', default='bar') From a52fd96b61e2498fd7a2f22c8f49a8b731deab81 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Fri, 20 Sep 2024 13:57:01 -0700 Subject: [PATCH 5/5] Update Doc/library/argparse.rst Co-authored-by: C.A.M. Gerlach --- Doc/library/argparse.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 751576e4ca8cd5..186d4fb285daeb 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -2124,9 +2124,8 @@ Parser defaults Namespace(bar=42, baz='badger', foo=736) Note that defaults can be set at both the parser level using :meth:`set_defaults` - and at the argument level using :meth:`add_argument`. If both are provided for the - same argument, the order of setting these defaults determines which one takes - precedence. The last default set for an argument is the one that is used:: + and at the argument level using :meth:`add_argument`. If both are called for the + same argument, the last default set for an argument is used:: >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--foo', default='bar')