@ilwdchar_compat<EOL>def write_tables(target, tables, append=False, overwrite=False, **kwargs):
from ligo.lw.ligolw import (Document, LIGO_LW, LIGOLWContentHandler)<EOL>from ligo.lw import utils as ligolw_utils<EOL>if isinstance(target, (Document, LIGO_LW)):<EOL><INDENT>xmldoc = target<EOL><DEDENT>elif append:<EOL><INDENT>xmldoc = open_xmldoc(<EOL>target, contenthandler=kwargs.pop('<STR_LIT>',<EOL>LIGOLWContentHandler))<EOL><DEDENT>elif (not overwrite and isinstance(target, string_types) and<EOL>os.path.isfile(target)):<EOL><INDENT>raise IOError("<STR_LIT>".format(target))<EOL><DEDENT>else:  <EOL><INDENT>xmldoc = Document()<EOL><DEDENT>write_tables_to_document(xmldoc, tables, overwrite=overwrite)<EOL>if isinstance(target, string_types):<EOL><INDENT>kwargs.setdefault('<STR_LIT>', target.endswith('<STR_LIT>'))<EOL>ligolw_utils.write_filename(xmldoc, target, **kwargs)<EOL><DEDENT>elif isinstance(target, FILE_LIKE):<EOL><INDENT>kwargs.setdefault('<STR_LIT>', target.name.endswith('<STR_LIT>'))<EOL>ligolw_utils.write_fileobj(xmldoc, target, **kwargs)<EOL><DEDENT>
Write an LIGO_LW table to file

    Parameters
    ----------
    target : `str`, `file`, :class:`~ligo.lw.ligolw.Document`
        the file or document to write into

    tables : `list`, `tuple` of :class:`~ligo.lw.table.Table`
        the tables to write

    append : `bool`, optional, default: `False`
        if `True`, append to an existing file/table, otherwise `overwrite`

    overwrite : `bool`, optional, default: `False`
        if `True`, delete an existing instance of the table type, otherwise
        append new rows

    **kwargs
        other keyword arguments to pass to
        :func:`~ligo.lw.utils.load_filename`, or
        :func:`~ligo.lw.utils.load_fileobj` as appropriate