File object question

Kent Johnson kent at kentsjohnson.com
Thu Dec 22 19:19:03 EST 2005


S. D. Rose wrote:
> Hello all.
>   If I read a binary file:
> 
> file = open('c:\\logo.gif', 'rw'') # Read from FS as one way to get the
> object, d/l from website another...
> file.read()
> 
> is there anyway I can determine the 'size' of the object file? (Without
> going to the filesystem and reading the filesize from the directory ...)

Once you have read the data you can get the size of that:
d = file.read()
print len(d)

Is that what you mean? Otherwise I don't know how you can get the size of a file without 
asking the filesystem...

Kent



More information about the Python-list mailing list