def stream_lines(stream, comments=None):
 try:
  readlines = stream.xreadlines
 except AttributeError:
  readlines = stream.readlines
 result = []
 for line in readlines():
  line = line.strip()
  if (line and ((comments is None) or (not line.startswith(comments)))):
   result.append(line)
 return result

def stream_lines ( stream , comments = None ) : try : readlines = stream . xreadlines except AttributeError : readlines = stream . readlines result = [ ] for line in readlines ( ) : line = line . strip ( ) if ( line and ( ( comments is None ) or ( not line . startswith ( comments ) ) ) ) : result . append ( line ) return result
return a list of non empty lines in the given stream .