Checking if a text file is blank
munichlinux at news.motzarella.org
Sun Apr 20 12:46:12 CEST 2008
elnoire at gmail.com wrote:
> Is there any way in python to check if a text file is blank?
obviously there are many ways, one simple way is to check length if its
None then the file is blank.
> What I've tried to do so far is:
> f = file("friends.txt", "w")
> if f.read() is True:
> """do stuff"""
> """do other stuff"""
If checking the file is blank is what you are tying to do then why do
you open the file in the write mode.
More information about the Python-list