Skip to content
Advertisement

Redirect all calls to print to a file

Consider this:

JavaScript

Is it possible to avoid reference to f in each line? Something like:

JavaScript

Advertisement

Answer

THis looks like task for contextlib.redirect_stdout, example usage

JavaScript

Warning: requires python3.4 or newer

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement