Skip to content

gh-148766: Add colour to Python help#148767

Open
hugovk wants to merge 1 commit intopython:mainfrom
hugovk:3.15-help-colour
Open

gh-148766: Add colour to Python help#148767
hugovk wants to merge 1 commit intopython:mainfrom
hugovk:3.15-help-colour

Conversation

@hugovk
Copy link
Copy Markdown
Member

@hugovk hugovk commented Apr 19, 2026

python --help (and especially --help-all) is a monochrome wall of text. Similar to argparse help, let's add some colour to add structure and improve readability.

Here's real screenshots of --help and termshot capture of --help-all:

Before After
--help
--help
--help-all
--help-all

📚 Documentation preview 📚: https://cpython-previews--148767.org.readthedocs.build/

@hugovk hugovk added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Apr 19, 2026
Comment thread Python/initconfig.c
* r = reset
* S = short option
* s = summary short option/action
* u = usage suffix
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u is unused.

Comment thread Python/initconfig.c
#if defined(MS_WINDOWS) && defined(HAVE_WINDOWS_CONSOLE_IO)
{
DWORD mode = 0;
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this also consider stderr (or maybe it does? I don't know Windows quirks).

Comment thread Python/initconfig.c
PyMem_RawFree(buf);
}
else {
fprintf(f, usage_line, program);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If PyMem_RawMalloc fails we will get the raw tags, no?

Comment thread Python/initconfig.c
return;
}
}
fprint_tagged(stdout, usage_envvars, 0);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need formatting here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review interpreter-core (Objects, Python, Grammar, and Parser dirs)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants