Forum Archive

sys.stdout.writelines()

achorrath233

I was trying out an example from the Python 2.7 documentation. It used sys.stdout.writelines(). This method failed with the following exception:

'StdoutCatcher' object has no attribute 'writelines'

What is StdoutCatcher?

omz

Thanks for noticing, this is a bug. StdoutCatcher is a class that is used internally to redirect output to the console UI in Pythonista. You normally don't have to worry about it.

The bug will be fixed in the next update. For now, you could replace the use of writelines in the sample code with something like this:

for line in lines:
    sys.stdout.write(line + '\n')