Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Doc/library/argparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2235,7 +2235,7 @@ Exiting methods
.. method:: ArgumentParser.exit(status=0, message=None)

This method terminates the program, exiting with the specified *status*
and, if given, it prints a *message* before that. The user can override
and, if given, it prints a *message* to stderr before that. The user can override
this method to handle these steps differently::

class ErrorCatchingArgumentParser(argparse.ArgumentParser):
Expand All @@ -2246,8 +2246,8 @@ Exiting methods

.. method:: ArgumentParser.error(message)

This method prints a usage message including the *message* to the
standard error and terminates the program with a status code of 2.
This method prints a usage message, including the *message*, to stderr
and terminates the program with a status code of 2.


Intermixed parsing
Expand Down
4 changes: 4 additions & 0 deletions Lib/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2620,6 +2620,10 @@ def _print_message(self, message, file=None):
# Exiting methods
# ===============
def exit(self, status=0, message=None):
"""exit(status=0, message=None)

Exit the program, optionally printing an exit message.
"""
if message:
self._print_message(message, _sys.stderr)
_sys.exit(status)
Expand Down
Loading