Skip to main content

ansiterm Package

ansiterm - change color and style (bold, reverse) of text on display

screenshot

DESCRIPTION

This manual page documents ansiterm module, a Python module providing functions for generating ANSI escape sequences to change the color and the style (i.e., bold and reverse) of text displayed on the screen.

A majority of terminal emulators support ANSI escape sequences. ansiterm module provides handy functions for changing the color and the style.

Please refer to https://en.wikipedia.org/wiki/ANSI_escape_code for the introduction of ANSI escape sequences.

EXAMPLE

from ansiterm import color

for bold in (False, True):
    for reverse in (False, True):
        for name in [
                'reset', 'bold', 'underline', 'reverse', 'gray', 'red',
                'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'
        ]:
            astr = color('text in {} with bold={}, reverse={}'.format(
                name, bold, reverse),
                         name,
                         bold=bold,
                         reverse=reverse)
            print(astr)

FUNCTIONS

ansiterm module provides the following functions.

  • color(astr, name='bold', bold=False, reverse=False)

    Embed ANSI escape sequences around string ASTR to change the text style to NAME. Make the text boldface and reversed video if BOLD or REVERSE is True, respectively.

The following functions are provided as short-cuts. For instance, blue(astr) and reest(astr) are equivalent to color(astr, 'blue') and color(astr, 'reset), respectively.

  • reset(astr, bold=False, reverse=False)

  • bold(astr, bold=True, reverse=False)

  • gray(astr, bold=False, reverse=False)

  • red(astr, bold=False, reverse=False)

  • green(astr, bold=False, reverse=False)

  • yellow(astr, bold=False, reverse=False)

  • blue(astr, bold=False, reverse=False)

  • magenta(astr, bold=False, reverse=False)

  • cyan(astr, bold=False, reverse=False)

  • white(astr, bold=False, reverse=False)

INSTALLATION

pip3 install ansiterm

AVAILABILITY

The latest version of ansiterm module is available at PyPI (https://pypi.org/project/ansiterm/) .

SEE ALSO

perl(1), perlfunc(1), getopt(3), Getopt::Std(3perl)

AUTHOR

Hiroyuki Ohsaki <code[atmark]lsnl.jp>

Metadata

Release files for ansiterm 1.2

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

Source distribution (sdist)

Source distribution for ansiterm 1.2
File Size Uploaded Provenance
ansiterm-1.2.tar.gz 15.0 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 30.8 kB

Release files / ansiterm-1.2.tar.gz

Download URL ansiterm-1.2.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
99628f4dbea1bf65d636d49a09bad91efb6da89dca984aa87f32cee8101173c7
BLAKE2b-256 checksum
How to use checksums
fb56826e86ad736f361e4c9cc69b95548fd7357af1b3e55bd17f8353eddc27ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / ansiterm-1.2-py3-none-any.whl

Download URL ansiterm-1.2-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
89b3f13a97ed07f096f2f281e0acc7bcd326a7ae3261e5966220a671733e81b8
BLAKE2b-256 checksum
How to use checksums
f6c71529a27b572bdceed96095e1b5c5cc0219912b361435191889f6a0b22187
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for ansiterm 1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.2 This release

2 release files No provenance

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