Jul-23-2021, 07:08 AM
(This post was last modified: Jul-23-2021, 07:08 AM by Gribouillis.)
This code looks a little strange to me because usually
Apart from that, you could perhaps write a separate function
that would write all of outbuf into outfile, similarly to
write()
functions return the amount of data written (see for example io.BufferedWriter.write()). This data written should be at the beginning of outbuf and the code seems to chop the end of outbuf. Also the variable name 'rem' is misleading, it looks like 'remaining data' which is wrong.Apart from that, you could perhaps write a separate function
def writeall(outfile, outbuf): ...
that would write all of outbuf into outfile, similarly to
socket.sendall()
vs socket.send()
. Of course this function would read computed slices of outbuf without ever reassigning outbuf or one of its slices.