Skip to main content

PyPI version Argparse_Formatter Tests Coverage

12/20/25 - FlexiHelpFormatter is making progress in the review process. I'm replacing the formatter code here with that submission, with aliases with the old names, for use with older Python versions.

Argparse Paragraph Formatter

This project is a simple Python module that provides an improved paragraph lovin formatter for argparse. This formatter respects paragraphs and bullet lists, providing consistent word wrapping.

Background

By default, argparse will collapse and transform all sequences of whitespace into a single space, and then wrap the text to an appropriate line length. This causes all text to be transformed into a single paragraph.

There are optional RawDescriptionHelpFormatter and RawTextHelpFormatter classes that can be used to preserve paragraphs, but they do not perform any word wrapping. What is needed are formatters that support more flexibility while still providing word wrapping.

The ParagraphFormatter

This module provides the ParagraphFormatter class. If this class is passed to the argparse.ArgumentParser creation call as the formatter_class argument, then help and epilog paragraphs, separated by single blank lines, will be preserved. Word wrapping will be performed within the paragraphs.

Note that ParagraphFormatter is implemented by overriding two private methods in the default argparse formatter, and that the internals of that class are not considered part of the argparse API. There is therefore a (vanishingly) small risk that the code may break with a future standard library release. The module has been tested across all supported Python 3 versions.

The ParagraphHelpFormatter

This module provides that FlexiFormatter class, with some modifications. This formatter preserves line feeds and indentation, and understands bullet lists.

Supported list styles are as follows:

    * item
    - item
    + item
    > item
    A. item
    1. item
    key: item

ParagraphHelpFormatter has been submitted for inclusion in Python3.15 - PR22129.

Demo

The flexidemo.py script shows the output for ParagraphHelpFormatter

*************************
Using the Default formatter
*************************

usage: flexidemo.py [-h] [--arg ARG]

optional arguments:
  -h, --help  show this help message and exit
  --arg ARG   This same feature would be useful for arguments that would
              benefit from more explanation. 1. It looks nicer 2. It is easier
              to read, even if some of the bullets get to be a little long.

This is a multi-paragraph epilog. It is presenting data that would benefit by
being visually broken up into pieces. It sure would be nice if it was
represented that way. 1. This is a pretty long line, in a bullet list -
getting longer and longer and longer 2. this isn't


*************************
Using the Flexi formatter
*************************

usage: flexidemo.py [-h] [--arg ARG]

optional arguments:
  -h, --help  show this help message and exit
  --arg ARG   This same feature would be useful for arguments that would
              benefit from more explanation.
               
                * It looks nicer
                * It is easier to read, even if some of the bullets get to be
                   a little long.
     
This is a multi-paragraph epilog. It is presenting data that would benefit by
being visually broken up into pieces.
 
It sure would be nice if it was represented that way.
 
  1. This is a pretty long line, in a bullet list - getting longer and longer
     and longer
  2. this isn't

Install

Install from PyPi with:

pip install argparse-formatter

Metadata

Release files for argparse-formatter 1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for argparse-formatter 1.5
File Size Uploaded
argparse_formatter-1.5.tar.gz 12.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for argparse-formatter 1.5
File Interpreter ABI Platform
argparse_formatter-1.5-py3-none-any.whl Python 3 none any Details

Total release size: 23.5 kB

Release files / argparse_formatter-1.5.tar.gz

Download URL argparse_formatter-1.5.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
877164d0a983689d3f48070f959c2d165dffc6074813b4479088d105b6a3dbff
BLAKE2b-256 checksum
How to use checksums
1785b57378b2be4e14fdf6a03d6bbf2147e1c9e5d6e812dd1a89e0382fe91153
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / argparse_formatter-1.5-py3-none-any.whl

Download URL argparse_formatter-1.5-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52b48e7834e40d4a61d22b8e13f9eff9bd6e170b1be5717861c546fc6722f635
BLAKE2b-256 checksum
How to use checksums
e79e55d62e096f32596bbf9dfc046c4fb9b3b0edffe915a98eb63f4cc392b4ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release history Release notifications | RSS feed

This release

1.5 This release

2 release files

1.4

2 release files

1.3

2 release files

1.2

1 release file

1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page