def replace_line(existing_line, new_line):
 try:
  f = open('/etc/locale.gen', 'r')
  lines = [line.replace(existing_line, new_line) for line in f]
 finally:
  f.close()
 try:
  f = open('/etc/locale.gen', 'w')
  f.write(''.join(lines))
 finally:
  f.close()

def replace_line ( existing_line , new_line ) : try : f = open ( '/etc/locale.gen' , 'r' ) lines = [ line . replace ( existing_line , new_line ) for line in f ] finally : f . close ( ) try : f = open ( '/etc/locale.gen' , 'w' ) f . write ( '' . join ( lines ) ) finally : f . close ( )
replaces lines in /etc/locale .