From d06f897f524c76e67c1067a9eef2d5ecec37d020 Mon Sep 17 00:00:00 2001 From: jay817 Date: Fri, 27 Sep 2024 08:39:56 -0400 Subject: [PATCH] Update color/README.md --- color/README.md | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/color/README.md b/color/README.md index c6de5ca..1492943 100644 --- a/color/README.md +++ b/color/README.md @@ -1,12 +1,5 @@ ```python -color = lambda ansi, text: f"\x1b[{ansi}m{text}\x1b[0m" -for name, ansi in zip("red green yellow blue magenta cyan".split(), range(91, 97)): - setattr(color, name, lambda text, ansi=ansi: color(ansi, text)) - -print(color.red("Red")) -print(color.green("Green")) -print(color.yellow("Yellow")) -print(color.blue("Blue")) -print(color.magenta("Magenta")) -print(color.cyan("Cyan")) +globals().update({color: lambda text, ansi=ansi: f'\x1b[{ansi}m{text}\x1b[0m' + for color, ansi in zip("red green yellow blue magenta cyan".split(), range(91, 97))}) +print(red('hello')) ``` \ No newline at end of file