catching empty strings (I guess that's what they are)

brad byte8bits at gmail.com
Mon Jul 9 10:27:31 EDT 2007


I've began accepting user input :( in an old program. The input comes 
from a simple text file where users enter filenames (one per line). What 
is the appropriate way to handle blank lines that hold whitespace, but 
not characters? Currently, I'm doing this:

      for user_file in user_files:
             # Remove whitespace and make lowercase.
             file_skip_list.append(user_file.strip().lower())

      file_skip_list = list(sets.Set(file_skip_list))

However, if the input file has blank lines in it, I get this in my list:

'' (that's two single quotes with noting in between)

I thought I could do something like this:

if user_file == None:
     pass

Or this:

if user_file == '':
     pass

But, these don't work, the '' is still there. Any suggestions are 
appreciated!

Brad



More information about the Python-list mailing list