Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to colorise the Python REPL? [closed]

python Repl

Vim

As we can see the difference between the images. In Vim, variable and function are of different color. How can I bring color to my Python REPL?

I want to do it by myself. Please suggest me how to do this. Whether I should have to do something with stdout stream object or I have to change something in Python interpreter and then build it from source?

like image 238
Prince Roshan Avatar asked Nov 15 '25 22:11

Prince Roshan


1 Answers

You should probably have searched a little bit more first, because there are many answers here about this. Perhaps the best ones are:

  • bpython [NOT on Windows without hack.]
  • ipython
  • Change Python interactive prompt ">>>"
  • Some characters stick to my colorized prompt in Python cmd
  • Adding colors in python interpreter prompt, does not wrap properly
  • How to fix column calculation in Python readline if using color prompt

Other Attmepts to improve the python REPL:

  • https://github.com/prompt-toolkit/ptpython - A python package

However, I find PtPython trying to do too much, and thus have a bloated dependency structure on: appdirs, jedi, prompt_toolkit, pygments, and indirectly to tox, wcwidth, parso, and possibly more, which is why I prefer my own no-nonsense 3-line ~/.pyrc solution for trivial changes as asked in this question.

like image 62
not2qubit Avatar answered Nov 18 '25 13:11

not2qubit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!