file size

Matthew Dixon Cowles matt at mondoinfo.com
Fri Sep 8 15:23:26 EDT 2000


On Fri, 08 Sep 2000 19:04:04 GMT, Keith Murphy <kpmurphy at my-deja.com>
wrote:
>how can i get the size of a file in python?
>
>i've done:
>	self.logfile = open(filename, 'a')
>and i'd like to do this next:
>	len_log = self.logfile.size()
>
>...is there something comparable?

Keith,
There's something comparable but it doesn't work just that way.  You
want something like:

import os
import stat
os.stat("foo")[stat.ST_SIZE]

Regards,
Matt



More information about the Python-list mailing list