How to check whether a file is empty or not?

webminal.org picture webminal.org · Mar 24, 2010 · Viewed 285.7k times · Source

I have a text file.
How can I check whether it's empty or not?

Answer

ghostdog74 picture ghostdog74 · Mar 24, 2010
>>> import os
>>> os.stat("file").st_size == 0
True