icecream
icecream copied to clipboard
Add option to change or disable colors
For people having problem with colors like me it is very important. Because with the default pretty print colors I can barely see what is written, I have to make a big effort to read it. So I would better prefer just disable the colors all together. Or choosing the colors would be great also.
I guess adding the option to disable colors is easy. It would be very nice if someone could quickly implement this.
Thanks a lot
I have the same issue. As far as I am aware this is not currently implemented. You could manually create this context manager I believe to implement this behavior (stolen from the unittests). Its not ideal if you want to disable it for the whole file.
from contextlib import contextmanager
from icecream import ic, stderrPrint
@contextmanager
def disableColoring():
originalOutputFunction = ic.outputFunction
ic.configureOutput(outputFunction=stderrPrint)
yield
ic.configureOutput(outputFunction=originalOutputFunction)
ic("This has coloring")
with disableColoring():
ic("This has no coloring!)
ic{"This has coloring again") ```
Also found this suggestion which might work better
import sys
from icecream import ic
ic.configureOutput(outputFunction=lambda *a: print(*a, file=sys.stderr))
Made a PR to implement this feature
https://github.com/gruns/icecream/pull/157
Ok , Thanks a lot. Having the ability to choose color would be the best , I really hope they implement it. For now I will try just that. Thank you @fanoway
On Windows the colors are really buggy. I want to turn them off immediately.
Try ycecream: pip install ycecream Github: https://github.com/salabim/ycecream
You will love it!