File object question

Tim Williams (gmail) tdwdotnet at gmail.com
Thu Dec 22 18:30:51 EST 2005


On 22/12/05, S. D. Rose <s_david_rose at hotmail.com> 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 ...


On my w2k box I use this for binary files

file = open('c:\\logo.gif', 'r+b'') # Read from FS as one way to get the
object, d/l from website another...
file_read = file.read()
len(file_read)

Note:  you must specify the binary option for binary files or you may not
get the whole file.

HTH :)

--

Tim Williams
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051222/a78d65e0/attachment.html>


More information about the Python-list mailing list