3
IRonnyc
7y

After trying to print colored text to the console using a portable Python 3 interpreter on Windows I came up with a "solution". I tried pretty much everything possible (I could think of): curses couldn't be loaded, ansi didn't work and installing libraries wasn't really an option, because it's not my device. Fuck portable interpreters and have fun with the "solution".

Def color_print(text, color):
text = text.replace("\n", "\\\" \\\"")
os.system ("powershell \"$host.ui.RawUi.ForegroundColor = \\\"" + color + "\\\"; echo \\\"" + test + "\\\"; $host.ui.RawUi.ForegroundColor = \\\"Gray\\\"")

It's slow, unreadable, only works for on Windows and requires powershell and is probably the worst piece of code I ever wrote, but it works ๐Ÿ‘.

Comments
  • 0
    I wrote a library just for fun for Unix like systems (or ansi lol) but if u do come up with a method that works without power shell then pls contribute here lol (btw it's in python and don't mind if u find it shitty, I was 15 lol)

    https://github.com/hrik2001/rikolor
  • 1
    Btw welcome to DevRant
Add Comment