python - printing long string with a single write call -
i found quite unexpected feature(or bug ?) when trying write long string single write
call using python (python 2.7.3-32 bit, windows 7).
calling print "a"*4000
prints on stdout line seems ok calling print "a"*5000
produces line 5000 white spaces instead of 'a' character.
would have idea of going wrong , how can circumvent problem ?
additional information:
using newer version of python (2.7.5) still produces same error. here snippet produces aformentionned problem.
f = open("toto.dat","w",1000000) s = "a"*5000 f.write(s) f.write("\n") f.close()
thanks lot.
eric
maybe problem of buffer ?
try please:
from os import fsync fh = open("test.dat","w") s = "a"*5000 fh.write(s) fh.write("\n") fh.flush() fsync(fh.fileno()) fh.close()
there's no reason closing file-handler wouldn't empty buffer , write in file, far know, knows ?....
Comments
Post a Comment