I am working on a code in Python 2.7. I use a very specific library written partially in C with a Python API. This library uses printf to output to stdout. I would like to suppress that. I already found this question: How do I prevent a C shared library to print on stdout in python? All of the provided answers use sys.stdout.fileno(). When I run my code I get:
original_stdout_fd = sys.stdout.fileno()
AttributeError: 'FlushingStringIO' object has no attribute 'fileno'
I suspect the problem is that I am using Python 2.7. Are my assumptions correct and is there a way to achieve this with Python 2.7?