1

I don't want to print colored text in the terminal. I want the Terminal itself to colourise the output based on its data type.

For example: I'm printing a python variable in VScode terminal, and the output says 123. Now I want to know if its a String or Integer. I know I can print its data type and check, but its time consuming. I want to know if there's any way to make VScode terminal to display string and integer in different color.

Code:

n = "123"
print(n)
print(int(n))

OUTPUT in VScode Terminal:

123
123

I'm using Macbook(M1) and my Macbook uses zsh (Z shell) within the terminal.

rioV8
  • 24,506
  • 3
  • 32
  • 49
dhayarp99
  • 11
  • 5
  • use the supplied link and write your own `print` routine that checks the type of the variable and sets the color you want. But be aware that if you don't output on a terminal, using a pipe, you get a lot of garbage in the output stream. You can write a print function that does this for any data structure passed as argument – rioV8 Jul 03 '23 at 07:14

0 Answers0