Skip to content
Advertisement

Python Argparse – How can I add text to the default help message?

I’m using python’s argparse to handle parsing of arguments. I get a default help message structured like so:

JavaScript

What I want is to add an entire new section to this message, for example:

JavaScript

Is there a way to achieve this behavior? A solution that is supported by both python 2.7 and 3.x is preferred.

Edit: I would also rather have a solution that will add the new section / sections at the bottom of the help message.

Advertisement

Answer

You can quite do it using epilog. Here is an example below:

JavaScript

Result :

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement