Put some better comments in TextColors. Add some colors to the output of 027_function
This commit is contained in:
parent
a921daa177
commit
59503067e6
|
@ -1,5 +1,7 @@
|
||||||
# A simple example of making a function
|
# A simple example of making a function
|
||||||
|
|
||||||
|
from Utils.TextColors import TextColors
|
||||||
|
|
||||||
# Functions are blocks of code that can be
|
# Functions are blocks of code that can be
|
||||||
# called/referenced from elsewhere in the code.
|
# called/referenced from elsewhere in the code.
|
||||||
# This can be useful if we need to do some common
|
# This can be useful if we need to do some common
|
||||||
|
@ -13,6 +15,6 @@ def you_baby(name):
|
||||||
|
|
||||||
your_name = None
|
your_name = None
|
||||||
while your_name != "":
|
while your_name != "":
|
||||||
your_name = input("What is your first name (hit <Enter> to quit): ")
|
your_name = input(TextColors.BRIGHT_BLUE + "What is your first name (" + TextColors.DARK_GRAY + "hit <Enter> to quit" + TextColors.BRIGHT_BLUE + "): " + TextColors.RESET)
|
||||||
if your_name != "":
|
if your_name != "":
|
||||||
print("Your name is", you_baby(your_name))
|
print(TextColors.BRIGHT_YELLOW + "Your name is " + you_baby(your_name) + TextColors.RESET)
|
|
@ -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:
|
class TextColors:
|
||||||
|
# These are all basically terminal control codes
|
||||||
|
# interpreted by most shells
|
||||||
BLACK = '\033[30m'
|
BLACK = '\033[30m'
|
||||||
RED = '\033[31m'
|
RED = '\033[31m'
|
||||||
GREEN = '\033[32m'
|
GREEN = '\033[32m'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user