1
+ from colorama import init , Fore , Back , Style
2
+
3
+ # essential for Windows environment
4
+ init ()
5
+ # all available foreground colors
6
+ FORES = [ Fore .BLACK , Fore .RED , Fore .GREEN , Fore .YELLOW , Fore .BLUE , Fore .MAGENTA , Fore .CYAN , Fore .WHITE ]
7
+ # all available background colors
8
+ BACKS = [ Back .BLACK , Back .RED , Back .GREEN , Back .YELLOW , Back .BLUE , Back .MAGENTA , Back .CYAN , Back .WHITE ]
9
+ # brightness values
10
+ BRIGHTNESS = [ Style .DIM , Style .NORMAL , Style .BRIGHT ]
11
+
12
+
13
+ def print_with_color (s , color = Fore .WHITE , brightness = Style .NORMAL , ** kwargs ):
14
+ """Utility function wrapping the regular `print()` function
15
+ but with colors and brightness"""
16
+ print (f"{ brightness } { color } { s } { Style .RESET_ALL } " , ** kwargs )
17
+
18
+ # printing all available foreground colors with different brightness
19
+ for fore in FORES :
20
+ for brightness in BRIGHTNESS :
21
+ print_with_color ("Hello world!" , color = fore , brightness = brightness )
22
+
23
+ # printing all available foreground and background colors with different brightness
24
+ for fore in FORES :
25
+ for back in BACKS :
26
+ for brightness in BRIGHTNESS :
27
+ print_with_color ("A" , color = back + fore , brightness = brightness , end = ' ' )
28
+ print ()
0 commit comments