tartley / colorama

Simple cross-platform colored terminal text in Python
BSD 3-Clause "New" or "Revised" License
3.55k stars 253 forks source link

Provide possibility to wrap separately either stdout or stderr #256

Open barabanus opened 4 years ago

barabanus commented 4 years ago

It's common to use stdout to generate binary files and stderr to print log and errors. At the same time colorama provides very convenient functionality to strip color codes from streams when output is redirected. The problem is that colorama wraps both stdout and stderr which strips binary symbols from stdout when binary files are generated.

It would be very useful for colorama library to wrap separately stderr / stdout on demand during initialization. I suggest to reuse 'wrap' argument to colorama.init() like this:

colorama.init()
colorama.init(wrap=False)
colorama.init(wrap="stdout")
colorama.init(wrap="stderr")
barabanus commented 4 years ago

I created a pull request #257, check it please.