color50
Last updated January 2024
Course Project: CS50P at Harvard University

Developer Credits
- Developed by Daniel Fletcher
Project Link
Link will open in a new tab.
Skills & Technologies
- Python
- PyPI
- Sphinx
Project Details
A lightweight Python package for printing more colorful output at the command line.
For my final project submission in Harvard University's CS50P course, I wanted to challenge myself to learn something entirely new related to the Python language. Something that's always interested me is the logistics behind creating and distributing a Python package for other developers to use in their projects, so I ultimately decided to make that the focus of my project. After some further brainstorming, I came to the conclusion that I wanted to create a Python package to help streamline the process of printing text in color at the terminal. This is another thing I've always been fascinated by but never really looked into before, so I thought it would be a great fit to pair with the package idea.
The final result is color50, a Python package consisting of four modules, two classes, multiple helper functions, and a series of named constants. See below for a brief summary of the package contents, and check out the Usage Guide or Demo Files sections of the documentation for some simple demonstrations!
color50 package contents:
-
color module – Contains the custom
Color
class and related functionality.-
Color
class – A custom class for storing and using colors in Python. Stores colors internally as the color's corresponding RGB values.
-
-
core_functions module – Contains four standalone functions that enable more intuitive color generation and usage.
-
rgb
function – Returns a validColor
object based on the RGB values passed as parameters. -
hexcode
function – Returns a validColor
object based on the HEX color code passed as a parameter. -
css
function – Returns a validColor
object based on the CSS color name passed as a parameter. -
colorize
function – Returns a validColor
Intended for use as a decorator that enables a simple-yet-effective way to alter the color of the output for an entire function.
-
-
colorstr module – Contains the custom
ColorStr
class and related functionality.-
ColorStr
class – A custom class for storing and using colorful strings in Python. Provides separate properties for optional usage of both foreground and background color modifiers.
-
- constants module – Contains an assortment of pre-defined, string literal constants for interfacing more directly with ANSI color code sequencing.
This project ended up being much grander in scope than I originally anticipated; however, I still found it to be an extremely rewarding experience. I'm very happy with what I've learned, the experience I've gained, and how the project turned out! I hope other Python developers or CS50 students can find some utility in the color50 package.
And with that, I now must say:
This was CS50P!
Relevant links: