parameters: (name, data)
docstring: Write a file.
docstring_summary: Write a file.
docstring_tokens: Write a file .
function: def write_file(name, data):
    """ Write a file. """
    try:
      with open(name, 'w', encoding='utf-8') as f:
        # write the data
        if sys.version_info.major == 2:
          f.write(data.decode('utf-8'))
        else:
          f.write(data)
    except IOError as e:
      (errno, strerror) = e.args
      sys.stderr.write('Failed to write file ' + name + ': ' + strerror)
      raise
function_tokens: def write_file ( name , data ) : try : with open ( name , 'w' , encoding = 'utf-8' ) as f : # write the data if sys . version_info . major == 2 : f . write ( data . decode ( 'utf-8' ) ) else : f . write ( data ) except IOError as e : ( errno , strerror ) = e . args sys . stderr . write ( 'Failed to write file ' + name + ': ' + strerror ) raise