Is it somehow possible to have certain output appear in a different color in the IPython Notebook? For example, something along the lines of:
print(\"Hello
Using @Evert answer, here is a method that would wrap a list of tokens in red and return a highlighted string
def color_in_tokens(tokens, color_token_contains="_"):
"""
Highlights the tokens which contain 'color_token_contains'
:param tokens: list of strings
:param color_token_contains: str (the string for marking a token red)
:return: str
"""
return " ".join(["\x1b[31m%s\x1b[0m" % i if color_token_contains in i else i for i in tokens])
Just call print on the returned string: