From 8b616934b4da16f932cbe9ca7f9640bfb26048b9 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Wed, 18 Sep 2024 15:05:18 -0700 Subject: [PATCH 01/11] add quick reference for ArgumentParser --- Doc/library/argparse.rst | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index aa1341c8d4d4a8..1c5796246a354a 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -25,6 +25,25 @@ will figure out how to parse those out of :data:`sys.argv`. The :mod:`argparse` module also automatically generates help and usage messages. The module will also issue errors when users give the program invalid arguments. +Quick Links for :class:`ArgumentParser` +-------------------------------- +========================= =========================================================================================================== ================================================================================== +Name Description Values +========================= =========================================================================================================== ================================================================================== +prog_ The name of the program Defaults to ``os.path.basename(sys.argv[0])`` +usage_ The string describing the program usage +description_ A brief description of what the program does. Displayed between the usage_ and argument help +epilog_ Additional description of the program after the argument help +parents_ A list of :class:`ArgumentParser` objects whose arguments should also be included +formatter_class_ A class for customizing the help output :class:`~argparse.HelpFormatter` +prefix_chars_ The set of characters that prefix optional arguments Defaults to ``'-'`` +fromfile_prefix_chars_ The set of characters that prefix files from which additional arguments should be read Defaults to ``None`` (meaning arguments will never be treated as file references) +argument_default_ The global default value for arguments +allow_abbrev_ Allows long options to be abbreviated if the abbreviation is unambiguous ``True`` or ``False`` (default: ``True``) +conflict_handler_ The strategy for resolving conflicting optionals +add_help_ Add a ``-h/--help`` option to the parser ``True`` or ``False`` (default: ``True``) +exit_on_error_ Determines whether or not to exit with error info when an error occurs ``True`` or ``False`` (default: ``True``) +========================= ============================================================================================================= Core Functionality ------------------ @@ -53,8 +72,7 @@ the extracted data in a :class:`argparse.Namespace` object:: args = parser.parse_args() print(args.filename, args.count, args.verbose) - -Quick Links for add_argument() +Quick Links for :meth:`add_argument` ------------------------------ ============================ =========================================================== ========================================================================================================================== From 45c4a44044c6d376f3c5e2574c6ddca75f25f222 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Wed, 18 Sep 2024 19:38:56 -0700 Subject: [PATCH 02/11] fix warnings --- 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 1c5796246a354a..fd14a9b1c4b405 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -26,7 +26,7 @@ module also automatically generates help and usage messages. The module will also issue errors when users give the program invalid arguments. Quick Links for :class:`ArgumentParser` --------------------------------- +--------------------------------------- ========================= =========================================================================================================== ================================================================================== Name Description Values ========================= =========================================================================================================== ================================================================================== @@ -72,7 +72,7 @@ the extracted data in a :class:`argparse.Namespace` object:: args = parser.parse_args() print(args.filename, args.count, args.verbose) -Quick Links for :meth:`add_argument` +Quick Links for add_argument() ------------------------------ ============================ =========================================================== ========================================================================================================================== From 5243c6977f57d4425ee260ee4793b3f9866b1d8f Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Wed, 18 Sep 2024 19:43:03 -0700 Subject: [PATCH 03/11] more formatting --- Doc/library/argparse.rst | 2 +- test.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 test.py diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index fd14a9b1c4b405..4dfa4e5e6f87bf 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -43,7 +43,7 @@ allow_abbrev_ Allows long options to be abbreviated if the abbreviat conflict_handler_ The strategy for resolving conflicting optionals add_help_ Add a ``-h/--help`` option to the parser ``True`` or ``False`` (default: ``True``) exit_on_error_ Determines whether or not to exit with error info when an error occurs ``True`` or ``False`` (default: ``True``) -========================= ============================================================================================================= +========================= =========================================================================================================== ================================================================================== Core Functionality ------------------ diff --git a/test.py b/test.py new file mode 100644 index 00000000000000..cfeba5a76e4589 --- /dev/null +++ b/test.py @@ -0,0 +1,4 @@ +import argparse + +parser = argparse.ArgumentParser(description='Process some integers.') +parser.add_argument('integers', metavar='N', type=int, nargs= \ No newline at end of file From e557c02469876682eac6fd7e56cfb3c0af60adad Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Wed, 18 Sep 2024 19:43:44 -0700 Subject: [PATCH 04/11] remove test file; --- test.py | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 test.py diff --git a/test.py b/test.py deleted file mode 100644 index cfeba5a76e4589..00000000000000 --- a/test.py +++ /dev/null @@ -1,4 +0,0 @@ -import argparse - -parser = argparse.ArgumentParser(description='Process some integers.') -parser.add_argument('integers', metavar='N', type=int, nargs= \ No newline at end of file From 19bd06102fc4ed38372fcc97b18b4da2488eeef4 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Wed, 18 Sep 2024 19:44:30 -0700 Subject: [PATCH 05/11] newline --- Doc/library/argparse.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 4dfa4e5e6f87bf..f2aea39e69416a 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -75,6 +75,7 @@ the extracted data in a :class:`argparse.Namespace` object:: Quick Links for add_argument() ------------------------------ + ============================ =========================================================== ========================================================================================================================== Name Description Values ============================ =========================================================== ========================================================================================================================== From 3c90fc18b5e2ba02a12fd19c87ac1e2be4cabb9c Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Wed, 18 Sep 2024 19:44:52 -0700 Subject: [PATCH 06/11] newline --- 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 f2aea39e69416a..bab3d331e68e82 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -71,11 +71,11 @@ the extracted data in a :class:`argparse.Namespace` object:: args = parser.parse_args() print(args.filename, args.count, args.verbose) + Quick Links for add_argument() ------------------------------ - ============================ =========================================================== ========================================================================================================================== Name Description Values ============================ =========================================================== ========================================================================================================================== From 3920190ba894e4105d02e457bd2f91d4c8c5a515 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Wed, 18 Sep 2024 19:45:15 -0700 Subject: [PATCH 07/11] remove indent --- 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 bab3d331e68e82..3abeb3fe1fc055 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -71,7 +71,7 @@ the extracted data in a :class:`argparse.Namespace` object:: args = parser.parse_args() print(args.filename, args.count, args.verbose) - + Quick Links for add_argument() ------------------------------ From b1e5f76f01a26f72d36e47ccaf33e6dfc48bd26d Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Wed, 18 Sep 2024 20:52:06 -0700 Subject: [PATCH 08/11] remove macro --- 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 3abeb3fe1fc055..cd075d26de5963 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -25,7 +25,7 @@ will figure out how to parse those out of :data:`sys.argv`. The :mod:`argparse` module also automatically generates help and usage messages. The module will also issue errors when users give the program invalid arguments. -Quick Links for :class:`ArgumentParser` +Quick Links for ArgumentParser --------------------------------------- ========================= =========================================================================================================== ================================================================================== Name Description Values From 2000f32ead6cdf119478cc65868715e33df03131 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Wed, 18 Sep 2024 20:56:52 -0700 Subject: [PATCH 09/11] remove tilde --- 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 cd075d26de5963..f068cd41975cd9 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -35,7 +35,7 @@ usage_ The string describing the program usage description_ A brief description of what the program does. Displayed between the usage_ and argument help epilog_ Additional description of the program after the argument help parents_ A list of :class:`ArgumentParser` objects whose arguments should also be included -formatter_class_ A class for customizing the help output :class:`~argparse.HelpFormatter` +formatter_class_ A class for customizing the help output :class:`argparse.HelpFormatter` prefix_chars_ The set of characters that prefix optional arguments Defaults to ``'-'`` fromfile_prefix_chars_ The set of characters that prefix files from which additional arguments should be read Defaults to ``None`` (meaning arguments will never be treated as file references) argument_default_ The global default value for arguments From c1c90298fa35f3f3b85ca8a6960c17b44d8df074 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Wed, 18 Sep 2024 21:00:56 -0700 Subject: [PATCH 10/11] remove class --- 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 f068cd41975cd9..94f1cda3ede62f 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -35,7 +35,7 @@ usage_ The string describing the program usage description_ A brief description of what the program does. Displayed between the usage_ and argument help epilog_ Additional description of the program after the argument help parents_ A list of :class:`ArgumentParser` objects whose arguments should also be included -formatter_class_ A class for customizing the help output :class:`argparse.HelpFormatter` +formatter_class_ A class for customizing the help output ``argparse.HelpFormatter`` prefix_chars_ The set of characters that prefix optional arguments Defaults to ``'-'`` fromfile_prefix_chars_ The set of characters that prefix files from which additional arguments should be read Defaults to ``None`` (meaning arguments will never be treated as file references) argument_default_ The global default value for arguments From 730109576b97e26dd80df452d6acf2fa734f9cc1 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Mon, 23 Sep 2024 17:18:41 -0700 Subject: [PATCH 11/11] Address comments from rhettinger --- 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 94f1cda3ede62f..8cb4264d7615ed 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -32,12 +32,12 @@ Name Description ========================= =========================================================================================================== ================================================================================== prog_ The name of the program Defaults to ``os.path.basename(sys.argv[0])`` usage_ The string describing the program usage -description_ A brief description of what the program does. Displayed between the usage_ and argument help +description_ A brief description of what the program does epilog_ Additional description of the program after the argument help parents_ A list of :class:`ArgumentParser` objects whose arguments should also be included formatter_class_ A class for customizing the help output ``argparse.HelpFormatter`` prefix_chars_ The set of characters that prefix optional arguments Defaults to ``'-'`` -fromfile_prefix_chars_ The set of characters that prefix files from which additional arguments should be read Defaults to ``None`` (meaning arguments will never be treated as file references) +fromfile_prefix_chars_ The set of characters that prefix files to read additional arguments from Defaults to ``None`` (meaning arguments will never be treated as file references) argument_default_ The global default value for arguments allow_abbrev_ Allows long options to be abbreviated if the abbreviation is unambiguous ``True`` or ``False`` (default: ``True``) conflict_handler_ The strategy for resolving conflicting optionals