def readline ( file , skip_blank = False ) : while 1 : line = file . readline ( ) #print "every line: %r" % line if not line : return None if line [ 0 ] != '#' and not ( skip_blank and line . isspace ( ) ) : return line
python ignoring blank lines in reading a file
Read a line from provided file skipping any blank or comment lines
def readline( file, skip_blank=False ):
    """Read a line from provided file, skipping any blank or comment lines"""
    while 1:
        line = file.readline()
        #print "every line: %r" % line
        if not line: return None 
        if line[0] != '#' and not ( skip_blank and line.isspace() ):
            return line