termcolor


Nametermcolor JSON
Version 2.5.0 PyPI version JSON
download
home_pageNone
SummaryANSI color formatting for output in terminal
upload_time2024-10-06 19:50:04
maintainerHugo van Kemenade
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT
keywords ansi ansi color ansi colour color colour formatting termcolor terminal
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # termcolor

[![PyPI version](https://img.shields.io/pypi/v/termcolor.svg?logo=pypi&logoColor=FFE873)](https://pypi.org/project/termcolor)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/termcolor.svg?logo=python&logoColor=FFE873)](https://pypi.org/project/termcolor)
[![PyPI downloads](https://img.shields.io/pypi/dm/termcolor.svg)](https://pypistats.org/packages/termcolor)
[![GitHub Actions status](https://github.com/termcolor/termcolor/workflows/Test/badge.svg)](https://github.com/termcolor/termcolor/actions)
[![Codecov](https://codecov.io/gh/termcolor/termcolor/branch/main/graph/badge.svg)](https://codecov.io/gh/termcolor/termcolor)
[![Licence](https://img.shields.io/github/license/termcolor/termcolor.svg)](COPYING.txt)
[![Code style: Black](https://img.shields.io/badge/code%20style-Black-000000.svg)](https://github.com/psf/black)
[![Tidelift](https://tidelift.com/badges/package/pypi/termcolor)](https://tidelift.com/subscription/pkg/pypi-termcolor?utm_source=pypi-termcolor&utm_medium=referral&utm_campaign=readme)

## Installation

### From PyPI

```bash
python3 -m pip install --upgrade termcolor
```

### From source

```bash
git clone https://github.com/termcolor/termcolor
cd termcolor
python3 -m pip install .
```

### Demo

To see demo output, run:

```bash
python3 -m termcolor
```

## Example

```python
import sys

from termcolor import colored, cprint

text = colored("Hello, World!", "red", attrs=["reverse", "blink"])
print(text)
cprint("Hello, World!", "green", "on_red")

print_red_on_cyan = lambda x: cprint(x, "red", "on_cyan")
print_red_on_cyan("Hello, World!")
print_red_on_cyan("Hello, Universe!")

for i in range(10):
    cprint(i, "magenta", end=" ")

cprint("Attention!", "red", attrs=["bold"], file=sys.stderr)
```

## Text properties

| Text colors     | Text highlights    | Attributes  |
| --------------- | ------------------ | ----------- |
| `black`         | `on_black`         | `bold`      |
| `red`           | `on_red`           | `dark`      |
| `green`         | `on_green`         | `underline` |
| `yellow`        | `on_yellow`        | `blink`     |
| `blue`          | `on_blue`          | `reverse`   |
| `magenta`       | `on_magenta`       | `concealed` |
| `cyan`          | `on_cyan`          | `strike`    |
| `white`         | `on_white`         |             |
| `light_grey`    | `on_light_grey`    |             |
| `dark_grey`     | `on_dark_grey`     |             |
| `light_red`     | `on_light_red`     |             |
| `light_green`   | `on_light_green`   |             |
| `light_yellow`  | `on_light_yellow`  |             |
| `light_blue`    | `on_light_blue`    |             |
| `light_magenta` | `on_light_magenta` |             |
| `light_cyan`    | `on_light_cyan`    |             |

## Terminal properties

| Terminal     | bold    | dark | underline | blink      | reverse | concealed |
| ------------ | ------- | ---- | --------- | ---------- | ------- | --------- |
| xterm        | yes     | no   | yes       | bold       | yes     | yes       |
| linux        | yes     | yes  | bold      | yes        | yes     | no        |
| rxvt         | yes     | no   | yes       | bold/black | yes     | no        |
| dtterm       | yes     | yes  | yes       | reverse    | yes     | yes       |
| teraterm     | reverse | no   | yes       | rev/red    | yes     | no        |
| aixterm      | normal  | no   | yes       | no         | yes     | yes       |
| PuTTY        | color   | no   | yes       | no         | yes     | no        |
| Windows      | no      | no   | no        | no         | yes     | no        |
| Cygwin SSH   | yes     | no   | color     | color      | color   | yes       |
| Mac Terminal | yes     | no   | yes       | yes        | yes     | yes       |

## Overrides

Terminal colour detection can be disabled or enabled in several ways.

In order of precedence:

1. Calling `colored` or `cprint` with a truthy `no_color` disables colour.
2. Calling `colored` or `cprint` with a truthy `force_color` forces colour.
3. Setting the `ANSI_COLORS_DISABLED` environment variable to any value disables colour.
4. Setting the [`NO_COLOR`](https://no-color.org/) environment variable to any value
   disables colour.
5. Setting the [`FORCE_COLOR`](https://force-color.org/) environment variable to any
   value forces colour.
6. Setting the `TERM` environment variable to `dumb`, or using such a
   [dumb terminal](https://en.wikipedia.org/wiki/Computer_terminal#Character-oriented_terminal),
   disables colour.
7. Finally, termcolor will attempt to detect whether the terminal supports colour.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "termcolor",
    "maintainer": "Hugo van Kemenade",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "ANSI, ANSI color, ANSI colour, color, colour, formatting, termcolor, terminal",
    "author": null,
    "author_email": "Konstantin Lepa <konstantin.lepa@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/37/72/88311445fd44c455c7d553e61f95412cf89054308a1aa2434ab835075fc5/termcolor-2.5.0.tar.gz",
    "platform": null,
    "description": "# termcolor\n\n[![PyPI version](https://img.shields.io/pypi/v/termcolor.svg?logo=pypi&logoColor=FFE873)](https://pypi.org/project/termcolor)\n[![Supported Python versions](https://img.shields.io/pypi/pyversions/termcolor.svg?logo=python&logoColor=FFE873)](https://pypi.org/project/termcolor)\n[![PyPI downloads](https://img.shields.io/pypi/dm/termcolor.svg)](https://pypistats.org/packages/termcolor)\n[![GitHub Actions status](https://github.com/termcolor/termcolor/workflows/Test/badge.svg)](https://github.com/termcolor/termcolor/actions)\n[![Codecov](https://codecov.io/gh/termcolor/termcolor/branch/main/graph/badge.svg)](https://codecov.io/gh/termcolor/termcolor)\n[![Licence](https://img.shields.io/github/license/termcolor/termcolor.svg)](COPYING.txt)\n[![Code style: Black](https://img.shields.io/badge/code%20style-Black-000000.svg)](https://github.com/psf/black)\n[![Tidelift](https://tidelift.com/badges/package/pypi/termcolor)](https://tidelift.com/subscription/pkg/pypi-termcolor?utm_source=pypi-termcolor&utm_medium=referral&utm_campaign=readme)\n\n## Installation\n\n### From PyPI\n\n```bash\npython3 -m pip install --upgrade termcolor\n```\n\n### From source\n\n```bash\ngit clone https://github.com/termcolor/termcolor\ncd termcolor\npython3 -m pip install .\n```\n\n### Demo\n\nTo see demo output, run:\n\n```bash\npython3 -m termcolor\n```\n\n## Example\n\n```python\nimport sys\n\nfrom termcolor import colored, cprint\n\ntext = colored(\"Hello, World!\", \"red\", attrs=[\"reverse\", \"blink\"])\nprint(text)\ncprint(\"Hello, World!\", \"green\", \"on_red\")\n\nprint_red_on_cyan = lambda x: cprint(x, \"red\", \"on_cyan\")\nprint_red_on_cyan(\"Hello, World!\")\nprint_red_on_cyan(\"Hello, Universe!\")\n\nfor i in range(10):\n    cprint(i, \"magenta\", end=\" \")\n\ncprint(\"Attention!\", \"red\", attrs=[\"bold\"], file=sys.stderr)\n```\n\n## Text properties\n\n| Text colors     | Text highlights    | Attributes  |\n| --------------- | ------------------ | ----------- |\n| `black`         | `on_black`         | `bold`      |\n| `red`           | `on_red`           | `dark`      |\n| `green`         | `on_green`         | `underline` |\n| `yellow`        | `on_yellow`        | `blink`     |\n| `blue`          | `on_blue`          | `reverse`   |\n| `magenta`       | `on_magenta`       | `concealed` |\n| `cyan`          | `on_cyan`          | `strike`    |\n| `white`         | `on_white`         |             |\n| `light_grey`    | `on_light_grey`    |             |\n| `dark_grey`     | `on_dark_grey`     |             |\n| `light_red`     | `on_light_red`     |             |\n| `light_green`   | `on_light_green`   |             |\n| `light_yellow`  | `on_light_yellow`  |             |\n| `light_blue`    | `on_light_blue`    |             |\n| `light_magenta` | `on_light_magenta` |             |\n| `light_cyan`    | `on_light_cyan`    |             |\n\n## Terminal properties\n\n| Terminal     | bold    | dark | underline | blink      | reverse | concealed |\n| ------------ | ------- | ---- | --------- | ---------- | ------- | --------- |\n| xterm        | yes     | no   | yes       | bold       | yes     | yes       |\n| linux        | yes     | yes  | bold      | yes        | yes     | no        |\n| rxvt         | yes     | no   | yes       | bold/black | yes     | no        |\n| dtterm       | yes     | yes  | yes       | reverse    | yes     | yes       |\n| teraterm     | reverse | no   | yes       | rev/red    | yes     | no        |\n| aixterm      | normal  | no   | yes       | no         | yes     | yes       |\n| PuTTY        | color   | no   | yes       | no         | yes     | no        |\n| Windows      | no      | no   | no        | no         | yes     | no        |\n| Cygwin SSH   | yes     | no   | color     | color      | color   | yes       |\n| Mac Terminal | yes     | no   | yes       | yes        | yes     | yes       |\n\n## Overrides\n\nTerminal colour detection can be disabled or enabled in several ways.\n\nIn order of precedence:\n\n1. Calling `colored` or `cprint` with a truthy `no_color` disables colour.\n2. Calling `colored` or `cprint` with a truthy `force_color` forces colour.\n3. Setting the `ANSI_COLORS_DISABLED` environment variable to any value disables colour.\n4. Setting the [`NO_COLOR`](https://no-color.org/) environment variable to any value\n   disables colour.\n5. Setting the [`FORCE_COLOR`](https://force-color.org/) environment variable to any\n   value forces colour.\n6. Setting the `TERM` environment variable to `dumb`, or using such a\n   [dumb terminal](https://en.wikipedia.org/wiki/Computer_terminal#Character-oriented_terminal),\n   disables colour.\n7. Finally, termcolor will attempt to detect whether the terminal supports colour.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "ANSI color formatting for output in terminal",
    "version": "2.5.0",
    "project_urls": {
        "Changelog": "https://github.com/termcolor/termcolor/releases",
        "Homepage": "https://github.com/termcolor/termcolor",
        "Source": "https://github.com/termcolor/termcolor"
    },
    "split_keywords": [
        "ansi",
        " ansi color",
        " ansi colour",
        " color",
        " colour",
        " formatting",
        " termcolor",
        " terminal"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7fbedf630c387a0a054815d60be6a97eb4e8f17385d5d6fe660e1c02750062b4",
                "md5": "a7f44cd6975ff6cd5e052fa2616c2c22",
                "sha256": "37b17b5fc1e604945c2642c872a3764b5d547a48009871aea3edd3afa180afb8"
            },
            "downloads": -1,
            "filename": "termcolor-2.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a7f44cd6975ff6cd5e052fa2616c2c22",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 7755,
            "upload_time": "2024-10-06T19:50:02",
            "upload_time_iso_8601": "2024-10-06T19:50:02.097764Z",
            "url": "https://files.pythonhosted.org/packages/7f/be/df630c387a0a054815d60be6a97eb4e8f17385d5d6fe660e1c02750062b4/termcolor-2.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "377288311445fd44c455c7d553e61f95412cf89054308a1aa2434ab835075fc5",
                "md5": "26f496075070852b5d39762bbd14ec46",
                "sha256": "998d8d27da6d48442e8e1f016119076b690d962507531df4890fcd2db2ef8a6f"
            },
            "downloads": -1,
            "filename": "termcolor-2.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "26f496075070852b5d39762bbd14ec46",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 13057,
            "upload_time": "2024-10-06T19:50:04",
            "upload_time_iso_8601": "2024-10-06T19:50:04.115013Z",
            "url": "https://files.pythonhosted.org/packages/37/72/88311445fd44c455c7d553e61f95412cf89054308a1aa2434ab835075fc5/termcolor-2.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-06 19:50:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "termcolor",
    "github_project": "termcolor",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "termcolor"
}
        
Elapsed time: 0.35287s