def yield_lines(path):
 try:
  with open(path) as fh:
   for line in fh:
    line = line.strip()
    if ((not line) or line.startswith(u'#')):
     continue
    (yield line)
 except (IOError, OSError) as e:
  if (e.errno == ENOENT):
   raise StopIteration
  else:
   raise

def yield_lines ( path ) : try : with open ( path ) as fh : for line in fh : line = line . strip ( ) if ( ( not line ) or line . startswith ( u'#' ) ) : continue ( yield line ) except ( IOError , OSError ) as e : if ( e . errno == ENOENT ) : raise StopIteration else : raise
yield non-empty/non-comment lines of a string or sequence .