def write(u, path):
    print("writing to: %s" % path)
    # This function implementation was chosen to be compatible across Python 2/3.
    f = open(path, "wb")
    try:
        b = u.encode(FILE_ENCODING)
        f.write(b)
    finally:
        f.close()
Write a unicode string to a file (as utf-8).
dataset/ETHPy150Open defunkt/pystache/setup.py/write