Skip to main content

python-argparse-extras

Some helpers for python's argparse.

Currently, this package provides 3 HelpFormatter classes that you can extend and / or use with python's argparse module:

Contents

formatter.WideHelpFormatter

HelpFormatter which tries to use a given amount of the terminal width.

The maximum line length is determines by the class attribute percentage_of_line_length. This defaults to the full width (1.0). Override this class and set your own percentage.

This uses shutil.get_terminal_size() to determine the line length.

formatter.ThreeQuarterWidthHelpFormatter

A WideHelpFormatter subclass with its percentage_of_line_length set to three quarters of the terminal line length.

formatter.ThreeQuarterWidthDefaultsHelpFormatter

A ThreeQuarterWidthHelpFormatter subclass which also derives from argparse.ArgumentDefaultsHelpFormatter. This means that in addition to using 3/4 of the terminal line length, it also prints the argument defaults in the help text.

Installation & Usage

Install the package with your favourite python package manager:

pip install apextras

or directly into your pipenv:

pipenv install apextras

After that, you can use these classes in the same way as any other argparse.HelpFormatter subclass while creating your argument parser:

from apextras.formatter import WideHelpFormatter
parser = argparse.ArgumentParser(formatter_class=WideHelpFormatter)
parser.add_argument(...)
...

Metadata

Release files for apextras 0.9.1

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

Source distribution (sdist)

Source distribution for apextras 0.9.1
File Size Uploaded
apextras-0.9.1.tar.gz 2.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for apextras 0.9.1
File Interpreter ABI Platform
apextras-0.9.1-py3-none-any.whl Python 3 none any Details

Total release size: 6.7 kB

Release files / apextras-0.9.1.tar.gz

Download URL apextras-0.9.1.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0dd79bfd010ddd696c4b34050757a0dda4d56227276075573fd75442351e17b2
BLAKE2b-256 checksum
How to use checksums
e0223a8d20045a36f77dc134ad0217ff96377461b7ded0cef30d6258a3b11af4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.9

Release files / apextras-0.9.1-py3-none-any.whl

Download URL apextras-0.9.1-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
661817ef3eddba2ea8dc26c1f369cb6aba31e42576cb02c8858a3be7ae17b6c6
BLAKE2b-256 checksum
How to use checksums
560804ff733adc508d493f325bc7071276d1c778358f8b1884e6517b0060febd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.9.1 This release

2 release files

0.9.0

2 release files

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