Likelihood of IOError during print vs. write
- by jkasnicki
I recently encountered an IOError writing to a file on NFS. There wasn't a disk space or permission issue, so I assume this was just a network hiccup. The obvious solution is to wrap the write in a try-except, but I was curious whether the implementation of print and write in Python make either of the following more or less likely to raise IOError:
f_print = open('print.txt', 'w')
print >>f_print, 'test_print'
f_print.close()
vs.
f_write = open('write.txt', 'w')
f_write.write('test_write\n')
f_write.close()
(If it matters, specifically in Python 2.4 on Linux).