[New-bugs-announce] [issue39809] argparse: add max_text_width parameter to ArgumentParser

Luca report at bugs.python.org
Sun Mar 1 05:54:19 EST 2020


New submission from Luca <lucatrv at hotmail.com>:

It is often desirable to limit the help text width, for instance to 78 or 88 columns, regardless of the actual size of the terminal window.

Currently you can achieve this in rather cumbersome ways, for instance by setting "os.environ['COLUMNS'] = '80'" (but this requires the "os" module, which may not be needed otherwise by your module, and may lead to other undesired effects), or by writing a custom formatting class. IMHO there should be a simpler option for such a basic task.

I propose to add a max_text_width parameter to ArgumentParser. This would require only minor code changes to argparse (see attached patch), should I open a pull request on GitHub?

----------
components: Library (Lib)
files: argparse_max_text_width.patch
keywords: patch
messages: 363053
nosy: lucatrv
priority: normal
severity: normal
status: open
title: argparse: add max_text_width parameter to ArgumentParser
type: enhancement
versions: Python 3.9
Added file: https://bugs.python.org/file48939/argparse_max_text_width.patch

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39809>
_______________________________________


More information about the New-bugs-announce mailing list