pax_global_header00006660000000000000000000000064143431223670014517gustar00rootroot0000000000000052 comment=32eeb20ac63c3a9251642288be22babb9869c86b colorful-0.5.5/000077500000000000000000000000001434312236700133535ustar00rootroot00000000000000colorful-0.5.5/.github/000077500000000000000000000000001434312236700147135ustar00rootroot00000000000000colorful-0.5.5/.github/CODE_OF_CONDUCT.md000066400000000000000000000062161434312236700175170ustar00rootroot00000000000000# Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at tuxtimo@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] [homepage]: http://contributor-covenant.org [version]: http://contributor-covenant.org/version/1/4/ colorful-0.5.5/.github/FUNDING.yml000066400000000000000000000001251434312236700165260ustar00rootroot00000000000000# These are supported funding model platforms #github: timofurrer ko_fi: timofurrer colorful-0.5.5/.github/ISSUE_TEMPLATE/000077500000000000000000000000001434312236700170765ustar00rootroot00000000000000colorful-0.5.5/.github/ISSUE_TEMPLATE/bug_report.md000066400000000000000000000020701434312236700215670ustar00rootroot00000000000000--- name: Bug Report about: Create a bug report to help us improve colorful title: '' labels: '' assignees: '' --- **Important notices** Before you add a new report, we ask you kindly to acknowledge the following: [-] I have read the contributing guide lines at https://github.com/timofurrer/colorful/blob/master/.github/CONTRIBUTING.md [-] I have read and respect the code of conduct at https://github.com/timofurrer/colorful/blob/master/.github/CODE_OF_CONDUCT.md [-] I have searched the existing issues and I'm convinced that mine is new. **Describe the bug** A clear and concise description of what the bug is. **Environment and Version** * OS (incl. terminal and shell used): ... * Python Version: ... * colorful Version: ... **To Reproduce** A clear and concise description of steps to reproduce the behavior you are experiencing. **Expected behavior** A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. **Additional context** Add any other context about the problem here. colorful-0.5.5/.github/ISSUE_TEMPLATE/feature_request.md000066400000000000000000000020401434312236700226170ustar00rootroot00000000000000--- name: Feature Request about: Suggest an idea for a new feature or enhancement for colorful title: '' labels: '' assignees: '' --- **Important notices** Before you add a new request, we ask you kindly to acknowledge the following: [-] I have read the contributing guide lines at https://github.com/timofurrer/colorful/blob/master/.github/CONTRIBUTING.md [-] I have read and respect the code of conduct at https://github.com/timofurrer/colorful/blob/master/.github/CODE_OF_CONDUCT.md [-] I have searched the existing issues and I'm convinced that mine is new. **Is your Feature Request related to a problem? Please describe.** A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] **Describe the solution you'd like** A clear and concise description of what you want to happen. **Describe alternatives you've considered** A clear and concise description of any alternative solutions or features you've considered. **Additional context** Add any other context or screenshots about the Feature Request here. colorful-0.5.5/.github/ISSUE_TEMPLATE/question.md000066400000000000000000000013071434312236700212700ustar00rootroot00000000000000--- name: Ask a Question about: Ask a Question about colorful (Usage, Development, ...) title: '' labels: '' assignees: '' --- **Important notices** Before you add a new report, we ask you kindly to acknowledge the following: [-] I have read the contributing guide lines at https://github.com/timofurrer/colorful/blob/master/.github/CONTRIBUTING.md [-] I have read and respect the code of conduct at https://github.com/timofurrer/colorful/blob/master/.github/CODE_OF_CONDUCT.md [-] I have searched the existing issues and I'm convinced that mine is new. **Ask your Question** Ask your question here! If the question is related to a particular environment or behavior please make sure to add some context. colorful-0.5.5/.github/workflows/000077500000000000000000000000001434312236700167505ustar00rootroot00000000000000colorful-0.5.5/.github/workflows/main.yml000066400000000000000000000043251434312236700204230ustar00rootroot00000000000000name: Continuous Integration on: [push] jobs: build: runs-on: ${{ matrix.os }} strategy: fail-fast: false max-parallel: 8 matrix: python-version: [3.7, 3.8, 3.9, "3.10", 3.11] os: [ubuntu-latest, windows-latest, macOS-latest] include: - os: ubuntu-18.04 python-version: 3.5 - os: ubuntu-18.04 python-version: 3.6 steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Setup build and test environment run: | python -m pip install --upgrade pip setuptools wheel - name: Build Python Package run: | python -m pip install -r requirements-dev.txt python -m pip install . - name: Lint with flake8 run: | pip install flake8 flake8 --show-source colorful/ tests/ - name: Test with pytest run: | coverage run --parallel -m pytest - name: Report code coverage run: | coverage combine coverage report coverage xml - name: Upload coverage to Codecov # codecov only runs on Linux if: startsWith(matrix.os, 'ubuntu-') uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.xml flags: unittests name: codecov-umbrella publish: needs: [build] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Set up Python 3.11 if: startsWith(github.event.ref, 'refs/tags') uses: actions/setup-python@v4 with: python-version: 3.11 - name: Build Package if: startsWith(github.event.ref, 'refs/tags') run: | python -m pip install --upgrade pip setuptools wheel python setup.py sdist bdist_wheel --universal - name: Publish Package on PyPI if: startsWith(github.event.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.pypi_token }} colorful-0.5.5/.gitignore000066400000000000000000000002561434312236700153460ustar00rootroot00000000000000# vim swap files *.swp # python bytecode files *.pyc __pycache__/ # test files .tox/ .cache/ # python setuptools *.egg-info/ # python virtualenvs env*/ # pycharm .idea/ colorful-0.5.5/CHANGELOG.md000066400000000000000000000100501434312236700151600ustar00rootroot00000000000000# Change Log All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] *Nothing here yet.* ## [v0.5.5] ## Fixed - Fix `setup(colormode=NO_COLORS)` - Fix correctnes of `__str__` to return always a str - Drop Python 2 support - Test Python 3.5 - Python 3.11 ## [v0.5.4] ## Fixed - `__getattr__` protocol implementation ## [v0.5.3] ## Fixed - Support equals protocol for ColorfulStyle objects ## [v0.5.2] ## Fixed - Expose the path to the built-in `colornames` color palette. Refs #31 ## [v0.5.1] ## Fixed - Removed placeholder artifacts (`[26m`) when coloring is disabled ## [v0.5.0] ## Added - Support for color names in a JSON file - Built-in support for [color-names](https://github.com/meodai/color-names) ## [v0.4.5] ## Fixed - Reading files in UTF-8 in setup.py ## [v0.4.4] ## Added - Official Python 3.7 support ## [v0.4.3] ## Fixed - Catch AttributeError in case sys.stdout was monkey patched. Refs #15 ## [v0.4.2] ## Fixed - If stdout default encoding is not set, UTF-8 is assumed ## [v0.4.1] ## Fixed - Support for Chinese and other languages requiring unicode. Refs #9 ## [v0.4.0] - Officially support PyPy 5.6, including Python 2 and 3 support ## [v0.3.12] - Improve support for nesting styles with `str.format()` ## [v0.3.11] - Support original module functionality for module hack ## [v0.3.10] - Add disable method ## [v0.3.9] ### Fixed - Augment add a `str()` to `ColorfulString` ## [v0.3.8] ### Added - Support creating unstyled ColorfulString ## [v0.3.7] ### Added - Support augmented add for ColorfulString's - Validate hex string for RGB colors ## [v0.3.6] ### Added - Combine and Pipe Styles ## [v0.3.5] ### Added - Support for Windows using colorama ## [v0.3.4] ### Added - Implement Colorful.print() method - Support env variable to point to local rgb.txt file ## [v0.3.3] This release is just to fix the PyPI project page. ## [v.0.3.2] ### Added - Support for styling objects which implement the `str()` protocol ## [v0.3.1] ### Added - Correctly support `len()` - Support nesting styles - Improved documentation ## [v0.3.0] - Initial release [Unreleased]: https://github.com/timofurrer/colorful/compare/v0.5.5...HEAD [v0.5.5]: https://github.com/timofurrer/colorful/compare/v0.5.4...v0.5.5 [v0.5.4]: https://github.com/timofurrer/colorful/compare/v0.5.3...v0.5.4 [v0.5.3]: https://github.com/timofurrer/colorful/compare/v0.5.2...v0.5.3 [v0.5.2]: https://github.com/timofurrer/colorful/compare/v0.5.1...v0.5.2 [v0.5.1]: https://github.com/timofurrer/colorful/compare/v0.5.0...v0.5.1 [v0.5.0]: https://github.com/timofurrer/colorful/compare/v0.4.5...v0.5.0 [v0.4.5]: https://github.com/timofurrer/colorful/compare/v0.4.4...v0.4.5 [v0.4.4]: https://github.com/timofurrer/colorful/compare/v0.4.3...v0.4.4 [v0.4.3]: https://github.com/timofurrer/colorful/compare/v0.4.2...v0.4.3 [v0.4.2]: https://github.com/timofurrer/colorful/compare/v0.4.1...v0.4.2 [v0.4.1]: https://github.com/timofurrer/colorful/compare/v0.4.0...v0.4.1 [v0.4.0]: https://github.com/timofurrer/colorful/compare/v0.3.12...v0.4.0 [v0.3.12]: https://github.com/timofurrer/colorful/compare/v0.3.11...v0.3.12 [v0.3.11]: https://github.com/timofurrer/colorful/compare/v0.3.10...v0.3.11 [v0.3.10]: https://github.com/timofurrer/colorful/compare/v0.3.9...v0.3.10 [v0.3.9]: https://github.com/timofurrer/colorful/compare/v0.3.8...v0.3.9 [v0.3.8]: https://github.com/timofurrer/colorful/compare/v0.3.7...v0.3.8 [v0.3.7]: https://github.com/timofurrer/colorful/compare/v0.3.6...v0.3.7 [v0.3.6]: https://github.com/timofurrer/colorful/compare/v0.3.5...v0.3.6 [v0.3.5]: https://github.com/timofurrer/colorful/compare/v0.3.4...v0.3.5 [v0.3.4]: https://github.com/timofurrer/colorful/compare/v0.3.3...v0.3.4 [v0.3.3]: https://github.com/timofurrer/colorful/compare/v0.3.2...v0.3.3 [v0.3.2]: https://github.com/timofurrer/colorful/compare/v0.3.1...v0.3.2 [v0.3.1]: https://github.com/timofurrer/colorful/compare/v0.3.0...v0.3.1 [v0.3.0]: https://github.com/timofurrer/colorful/compare/466cfeddee681c8221ab981018597c01...v0.3.0 colorful-0.5.5/LICENSE000066400000000000000000000020661434312236700143640ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2017 Timo Furrer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. colorful-0.5.5/MANIFEST.in000066400000000000000000000001331434312236700151060ustar00rootroot00000000000000include colorful/data/*.txt include colorful/data/*.json include README.md include LICENSE colorful-0.5.5/README.md000066400000000000000000000355731434312236700146470ustar00rootroot00000000000000# colorful [![Actions Status](https://github.com/timofurrer/colorful/workflows/Continuous%20Integration/badge.svg)](https://github.com/timofurrer/colorful/actions) [![codecov.io](https://codecov.io/github/timofurrer/colorful/coverage.svg?branch=master)](https://codecov.io/github/timofurrer/colorful?branch=master) [![PyPI version](https://badge.fury.io/py/colorful.svg)](https://badge.fury.io/py/colorful) [![PyPI](https://img.shields.io/pypi/pyversions/colorful.svg)](https://pypi.python.org/pypi/colorful) [![PyPI](https://img.shields.io/pypi/wheel/colorful.svg)](https://pypi.python.org/pypi/colorful) Terminal string styling done right, in Python :tada: ## Here's a tease ![colorful example](examples/basic_example.png) ```python import colorful as cf # create a colored string using clever method translation print(cf.bold_white('Hello World')) # create a colored string using `str.format()` print('{c.bold}{c.lightCoral_on_white}Hello World{c.reset}'.format(c=cf)) # nest colors print(cf.red('red {0} red'.format(cf.white('white')))) print(cf.red('red' + cf.white(' white ', nested=True) + 'red')) # combine styles with strings print(cf.bold & cf.red | 'Hello World') # use true colors cf.use_true_colors() # extend default color palette cf.update_palette({'mint': '#c5e8c8'}) print(cf.mint_on_snow('Wow, this is actually mint')) # choose a predefined style cf.use_style('solarized') # print the official solarized colors print(cf.yellow('yellow'), cf.orange('orange'), cf.red('red'), cf.magenta('magenta'), cf.violet('violet'), cf.blue('blue'), cf.cyan('cyan'), cf.green('green')) # directly print with colors cf.print('{c.bold_blue}Hello World{c.reset}') # choose specific color mode for one block with cf.with_8_ansi_colors() as c: print(c.bold_green('colorful is awesome!')) # create and choose your own color palette MY_COMPANY_PALETTE = { 'companyOrange': '#f4b942', 'companyBaige': '#e8dcc5' } with cf.with_palette(MY_COMPANY_PALETTE) as c: print(c.companyOrange_on_companyBaige('Thanks for choosing our product!')) # use f-string (only Python >= 3.6) print(f'{cf.bold}Hello World') # support for chinese print(cf.red('你好')) ``` ## Key Features * expressive and consistent API ([docs](#style-a-string)) * support for different color modes (8 ANSI, 256 ANSI, true colors) ([docs](#color-modes)) * support for predefined awesome styles (solarized, ...) ([docs](#styles)) * support for custom color palettes ([docs](#color-palette)) * support nesting styles ([docs](#nesting-styles)) * support for different platforms (using colorama on Windows) * context managers for clean color mode, color palette or style switch ([docs](#temporarily-change-colorful-settings)) * support `len()` on colored strings ([docs](#correctly-support-the-len-protocol)) * support color names from [X11 rgb.txt](https://en.wikipedia.org/wiki/X11_color_names) ([docs](#1-style-a-string-with-a-method-call-colorfulmodifiers_fgcolor_on_bgcolorstr-nestedfalse)) * no dependencies ## Usage **colorful** supports all major Python versions: *3.5*, *3.6* and *3.7*, *3.8*, *3.9*, *3.10*, *3.11*.
We recommend to use the latest version released on [PyPI](https://pypi.python.org/pypi/colorful): ```bash pip install colorful ``` **colorful** does not require any special setup in order to be used: ```python import colorful as cf print(cf.italic_coral_on_beige('Hello World')) print(cf.italic & cf.coral_on_beige | 'Hello World') print('{c.italic_coral_on_beige}Hello World{c.reset}'.format(c=cf)) ``` Note: the entire documentation assumes `colorful` to be imported as `cf`. See the [Style a string](https://github.com/timofurrer/colorful#style-a-string) section for more information! ### Color modes These days terminals not only support the ancient 8 ANSI colors but often they support up to 16 Million colors with *[true color](https://en.wikipedia.org/wiki/Color_depth#True_color_.2824-bit.29)*. And if they don't support *true color* they might support the *[256 ANSI color palette](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors)* at least. **colorful** supports the following color modes: * no colors / disable (``cf.NO_COLORS``) * 8 colors -> 8 ANSI colors (``cf.ANSI_8_COLORS``) * 256 colors -> 256 ANSI color palette (8bit ``cf.ANSI_256_COLORS``) * 16'777'215 colors -> true color (24bit, ``cf.TRUE_COLORS``) By default *colorful* tries to auto detect the best supported color mode by your terminal. Consult [`cf.terminal`](https://github.com/timofurrer/colorful/blob/master/colorful/terminal.py) for more details. However, sometimes it makes sense to specify what color mode should be used.
**colorful** provides multiple ways to do so: #### (1) specify color mode globally via Python API ```python cf.disable() cf.use_8_ansi_colors() cf.use_256_ansi_colors() cf.use_true_colors() ``` If you change the color mode during runtime it takes affect immediately and globally. #### (2) enforce color mode globally via environment variable ```bash COLORFUL_DISABLE=1 python eggs.py # this process will not use ANY coloring COLORFUL_FORCE_8_COLORS=1 python eggs.py # this process will use 8 ANSI colors by default COLORFUL_FORCE_256_COLORS=1 python eggs.py # this process will use 256 ANSI colors by default COLORFUL_FORCE_TRUE_COLORS=1 python eggs.py # this process will use true colors by default ``` #### (3) specify color mode locally via Python API (contextmanager) ```python with cf.with_8_ansi_colors() as c: print(c.italic_coral_on_beige('Hello world')) with cf.with_256_ansi_colors() as c: print(c.italic_coral_on_beige('Hello world')) with cf.with_true_colors() as c: print(c.italic_coral_on_beige('Hello world')) ``` ### Color palette **colorful**'s Python API is based on *color names* like in `cf.bold_white_on_black('Hello')`. During runtime these *color names* are translated into proper [ANSI escape code](https://en.wikipedia.org/wiki/ANSI_escape_code) sequences supported by the *color mode* in use. However, all *color names* are registered in a **color palette** which is basically a mapping between the *color names* and it's corresponding RGB value. Very much like this: ```python color_palette_example = { 'black': '#000000', 'white': '#FFFFFF', } ``` *Note: Depending on the color mode which is used the RGB value will be reduced to fit in the value domain of the color mode.* The default color palette is the [X11 rgb.txt](https://en.wikipedia.org/wiki/X11_color_names) palette - it's shipped with *colorful*, thus, you don't have to provide your own. *colorful* ships with a second built-in [color palette called *colornames*](https://codepen.io/meodai/full/VMpNdQ/). Those colors are from the curated list of the [color-names](https://github.com/meodai/color-names) repository. You can use those via the `cf.setup()` method, like this: ```python cf.setup(colorpalette=cf.COLORNAMES_COLORS) ``` If you wish to have another color palette from a file as your default color palette you can set the `COLORFUL_DEFAULT_COLOR_PALETTE` environment variable to this file: ```bash COLORFUL_DEFAULT_COLOR_PALETTE=/usr/share/X11/rgb.txt python spam.py ``` The file either has to be a txt file like the X11 rgb.txt or a JSON file: ```json [ {"name": "18th Century Green", "hex":"#a59344"}, {"name": "1975 Earth Red", "hex":"#7a463a"} ] ``` #### Custom color palette **colorful** supports to update or replace the default color palette with custom colors. The colors have to be specified as RGB hex or channel values: ```python # corporate identity colors ci_colors = { 'mint': '#c5e8c8', # RGB hex value 'darkRed': '#c11b55', # RGB hex value 'lightBlue': (15, 138, 191) # RGB channel triplet } # replace the default palette with my custom one cf.use_palette(ci_colors) # update the default palette with my custom one cf.update_palette(ci_colors) # we can use these colors print(cf.italic_mint_on_darkRed('My company')) ``` ### Styles **colorful** supports some famous color palettes using what's called *styles* in colorful: ```python cf.use_style('solarized') # print the official solarized colors print(cf.yellow('yellow'), cf.orange('orange'), cf.red('red'), cf.magenta('magenta'), cf.violet('violet'), cf.blue('blue'), cf.cyan('cyan'), cf.green('green')) ``` The following styles are already supported:
solarized - Website
solarized colors
monokai
monokai colors

*Note: if you know some awesome color palettes which could be a new style in colorful, please contribute it!* ### Style a string **colorful** provides multiple ways to use style a string. Most useful and expressive is probably the *method syntax* where you specify the modifiers and colors in the method name itself and pass the string as argument to this method. However, you can use all the following methods to achive similars things: #### (1) Style a string with a method call `cf.[]_[]_[on_](str, nested=False)` ```python print(cf.red('I am red')) print(cf.italic_yellow('I am italic and yellow')) print(cf.black_on_white('I am black on white')) ``` The method syntax can be one of: * `cf.` * `cf._` * `cf.` * `cf.on_` * `cf._` * `cf._` * `cf._on_` * `cf.__on_` *Note that multiple ``s can be specified at once.* Available modifiers are: * reset (explicitely reset all styles before the passed argument) * bold * dimmed (not widely supported) * italic * underlined * blinkslow * blinkrapid * inversed (not widely supported) * concealed (not widely supported) * struckthrough The available colors depend on the [color palette](#color-palette) you are using. By default all [X11 rgb.txt colors](https://en.wikipedia.org/wiki/X11_color_names) are available. The type of the return value of such a *style method* is `colorful.ColorfulString`. It correctly supports all `str()` methods including [`len()`](#correctly-support-the-len-protocol). As you can see from the syntax in the section name, **colorful** supports nesting styles. See [Nesting styles](#nesting-styles). #### (2) Style a string with `&` and `|` **colorful** implements the `__or__` and `__and__` protocol to combine styles and pipe strings into them: ```python print(cf.bold & cf.red | 'Hello World') print(cf.bold_red_on_black | 'Hello World') print(cf.bold | cf.red_on_black('Hello World') ``` *Note: the piping `|` has the same effect as doing a method call to the style.
So you could do `(cf.bold & cf.red)('Hello World')`* #### (3) Style a string with `cf.format(string, *args, **kwargs)` ```python print(cf.format('{c.red}I am {what}{c.close_fg_color}', what='red')) # alternatively to ``c.close_fg_color`` you can reset every style with ``c.reset`` print(cf.format('{c.red}I am red{c.reset}')) print(cf.format('{c.italic_yellow}I am italic and yellow{c.no_italic}{c.close_fg_color}')) print(cf.format('{c.black_on_white}I am black on white{c.close_fg_color}{c.close_bg_color}')) ``` **colorful** will replace the `{c.