[Python-ideas] Re: shutil.copyfileobj to return number of bytes copied

2022-03-06 Thread Steven D'Aprano
On Wed, Mar 02, 2022 at 01:08:41AM +, Davis, Matthew via Python-ideas wrote: > Hi, > > Currently shutil.copyfileobj returns nothing. > I would like to be able to find out how many bytes were copied. That seems reasonable to me. It would be a similar change to having file.write() return the n

[Python-ideas] Re: shutil.copyfileobj to return number of bytes copied

2022-03-06 Thread Davis, Matthew via Python-ideas
Hi Barry, I can’t use os.fstat. That only applies to real files, not file-like objects. I’m using streams for downloading, unzipping, gzipping and uploading data which is larger than my disk and memory. So it’s all file-like objects, not real files. A file-like object that just passes through d

[Python-ideas] Re: shutil.copyfileobj to return number of bytes copied

2022-03-02 Thread Barry
> On 2 Mar 2022, at 13:40, Davis, Matthew via Python-ideas > wrote: > >  > Hi, > > Currently shutil.copyfileobj returns nothing. > I would like to be able to find out how many bytes were copied. > > Whilst most file-like objects have a .tell() which you could use, some don’t, > and .tell()