file size 'mystery'
Jay O'Connor
joconnor at nets.com
Tue May 20 12:16:25 EDT 2003
In article <baddu9$dtj$1 at online.de>, "Sven Brandt"
<sven_NOSPAM at manastar.de> wrote:
> I'd like to determin the size of a file an do stuff at a certain size
> (here > 0 byte). In Python:
Take a look at os.stat(), you can use the os to tell you the file size
without reading the whole file in.
fstats = os.stat(my_file)
if fstats.st_size > 0:
print "file has stuff"
else:
print "file is empty"
Note: I think the file name you pass to os.stat() has to be the full path
name.
--
Jay O'Connor
http://www.r4h-music.com
"God Himself plays the bass strings first,
when He tunes the soul"
More information about the Python-list
mailing list