From 59503067e6b6e95f75ed31f92fc5a9ee8a6db3c5 Mon Sep 17 00:00:00 2001 From: Junior Date: Mon, 3 Jun 2024 20:18:25 -0400 Subject: [PATCH] Put some better comments in TextColors. Add some colors to the output of 027_function --- Python/027_function.py | 6 ++++-- Python/Utils/TextColors.py | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Python/027_function.py b/Python/027_function.py index 4f83388..34d2f56 100644 --- a/Python/027_function.py +++ b/Python/027_function.py @@ -1,5 +1,7 @@ # A simple example of making a function +from Utils.TextColors import TextColors + # Functions are blocks of code that can be # called/referenced from elsewhere in the code. # This can be useful if we need to do some common @@ -13,6 +15,6 @@ def you_baby(name): your_name = None while your_name != "": - your_name = input("What is your first name (hit to quit): ") + your_name = input(TextColors.BRIGHT_BLUE + "What is your first name (" + TextColors.DARK_GRAY + "hit to quit" + TextColors.BRIGHT_BLUE + "): " + TextColors.RESET) if your_name != "": - print("Your name is", you_baby(your_name)) \ No newline at end of file + print(TextColors.BRIGHT_YELLOW + "Your name is " + you_baby(your_name) + TextColors.RESET) \ No newline at end of file diff --git a/Python/Utils/TextColors.py b/Python/Utils/TextColors.py index bef5976..8e60618 100644 --- a/Python/Utils/TextColors.py +++ b/Python/Utils/TextColors.py @@ -1,4 +1,10 @@ +# This class is just a container for color names +# used when printing text to the console/terminal. +# To use: from Utils.TextColors import TextColors + class TextColors: + # These are all basically terminal control codes + # interpreted by most shells BLACK = '\033[30m' RED = '\033[31m' GREEN = '\033[32m'