Can I write italics to the Python shell?

italics, python

Solution

In Python 2 or 3 if your console supports italics, e.g. rxvt-unicode you can precede your Italic text with the ansi escape code for italics `\x1B[3m`, and then append it with `\x1B[0m` for reset/normal to return to normal characters.

>>> print("Normal text \x1B[3mitalic text\x1B[0m normal text")

Problem

Is it possible to write something like this: ``` >>> text_output = "Hello World." >>> print text_output ``` ...where if the text_output is printed to the Python Shell, it is printed in italics?

Original source