I am new to Python and having some trouble with the stderr.write function. I will try to illustrate it with code. Before I was doing this:
print "Unexpected error! File {0} could not be converted." .format(src)
But then I wanted to separate the error messages from other status messages so I tried doing this:
sys.stderr.write "Unexpected error! File %s could not be converted." src
But this results in error. I googled it as well but i couldn’t find anything. Could anyone please help me out here. How can I print the string src using stderr.write?
In Python 2.x:
Or, in Python 2.x and 3.x: