(file_name)
return open(file_name, 'w', encoding='utf-8')
Opens file ``filename`` for writing. If necessary, creates file directories on the path.

    :param file_name: Absolute or relative path that includes file name being created.
    :return: File descriptor created.
Opens file ``filename`` for writing. If necessary, creates file directories on the path.
Opens file filename for writing . If necessary creates file directories on the path .
def open_file_for_write(file_name):
    """
    Opens file ``filename`` for writing. If necessary, creates file directories on the path.

    :param file_name: Absolute or relative path that includes file name being created.
    :return: File descriptor created.
    """
    directory = os.path.dirname(file_name)

    if len(directory) > 0 and not os.path.exists(directory):
        os.makedirs(directory)

    return open(file_name, 'w', encoding='utf-8')
def open_file_for_write ( file_name ) : directory = os . path . dirname ( file_name ) if len ( directory ) > 0 and not os . path . exists ( directory ) : os . makedirs ( directory ) return open ( file_name , 'w' , encoding = 'utf-8' )