def write_file(filename, value, mode='w'):
    f = open(filename, mode)
    try:
        return f.write(value)
    finally:
        f.close()
writes <value> to filename, making sure to close the file explicitly on exit.
dataset/ETHPy150Open uwdata/termite-visualizations/web2py/gluon/fileutils.py/write_file