Well, the headline seems to me sufficient.
I use some function that at some points print something in the console.
As I can't modify them, I would like to know if there is a solution to not printing while using these functions.
Thanks a lot !
Yes, you can redirect
import sys import os sys.stdout = open(os.devnull, "w") my_nasty_function() sys.stdout = sys.__stdout__
my_nasty_function with your actual function.
EDIT: Now should work on windows aswell and makes use of
sys.__stdout__ instead of a backup variable.