os.path.getsize() on Windows

Paul M¢Nett p at ulmcnett.com
Fri Mar 21 22:09:39 CET 2008

Martin v. Löwis wrote:
>> def isGrowing(f, timeout):
>>         ssize = os.path.getsize(f)
>>         time.sleep(timeout)
>>         esize =os.path.getsize(f)
>>         return esize != ssize
>> On windows, this returns the size of the file as it _will be_, not the
>> size that it currently is. 
> Why do you say that? It most definitely returns what the size currently
> is, not what it will be in the future (how could it know, anyway).

I've seen this before, when copying a file in Windows. Windows reports 
the size the file will be after the copy is complete (it knows, after 
all, the size of the source file). I always thought this meant that 
Windows is just much smarter than me, so I ignored it.


More information about the Python-list mailing list