def count_lines(filename, non_empty=False):
 try:
  if non_empty:
   out = subprocess.Popen(['grep', '-cve', '^\\s*$', filename], stdout=subprocess.PIPE)
  else:
   out = subprocess.Popen(['wc', '-l', filename], stdout=subprocess.PIPE)
  return int(out.communicate()[0].split()[0])
 except:
  pass
 return 0

def count_lines ( filename , non_empty = False ) : try : if non_empty : out = subprocess . Popen ( [ 'grep' , '-cve' , '^\\s*$' , filename ] , stdout = subprocess . PIPE ) else : out = subprocess . Popen ( [ 'wc' , '-l' , filename ] , stdout = subprocess . PIPE ) return int ( out . communicate ( ) [ 0 ] . split ( ) [ 0 ] ) except : pass return 0
counting the number of lines from the filename file .