Skip to main content

Add color codes to strings or print in color.

Project description

incolor

Description

Very simple package that aims at adding some color to Your life.

Quickstart

  • Add color codes to text (uses color numbers)
>>> from incolor import incolor
>>> incolor(4, 'I\'m blue da ba dee')
"\x1b[34mI'm blue da ba dee\x1b[0m"
  • Add color codes to text (uses color names)
>>> from incolor import incolor, Color
>>> incolor(Color.blue, 'I\'m blue da ba dee')
"\x1b[34mI'm blue da ba dee\x1b[0m"
  • Join multiple arguments in colorful manner
>>> incolor(Color.brwhite, 'First', 2, 'third', list())
'\x1b[315mFirst 2 third []\x1b[0m'
  • Color print function (behaves exactly like print(incolor(...)) ) (the is yellow here)
>>> cprint(3, 'Yellow: 🚢', 123, 'yay')
Yellow: 🚢 123 yay
  • Both functions accept sep argument
>>> incolor(0, 'a', 1, 2, sep='\t')
'\x1b[30ma\t1\t2\x1b[0m'
>>> cprint(0, 'a', 1, 2, sep='\t')
a       1       2

Tests

To run tests execute test.sh script

./test.sh

Prerequisites:

  • docker
  • Internet connection 😃

#TODO

  • add colors only if output is a TTY
  • verify Windows support (probably not working?)
  • add more ways to specify colors (f.e. from string: 'red')
  • add support for 256 colors
  • add support for Truecolor

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

incolor-0.2.tar.gz (2.4 kB view hashes)

Uploaded Source

Built Distribution

incolor-0.2-py3-none-any.whl (3.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page