Dennis Lee Bieber wrote:
> On Tue, 23 May 2017 21:42:45 +0100, bartc <[email protected]> declaimed the
> following:
>
>>Is it necessary to sort them? If XXX is known, then presumably the first
>>file will be called XXX_chunk_0, the next XXX_chunk_1 and so on.
>>
>
> XXX_chunk_1
> XXX_chunk_10
> XXX_chunk_2
This is a problem you run into if you do sort the filenames (the wrong way,
alphabetically). If I understand Bart correctly he suggests something like
with open(DESTFILE, "wb") as outstream:
for filename in map("XXX_chunk_{}".format, itertools.count()):
try:
with open(filename, "rb") as instream:
shutil.copyfileobj(instream, outstream)
except FileNotFoundError:
break
--
https://mail.python.org/mailman/listinfo/python-list