def write(self, outfile):
if len(self) < <NUM_LIT:1>:<EOL><INDENT>print("<STR_LIT>"<EOL>"<STR_LIT>".format(outfile))<EOL>try:<EOL><INDENT>outf = _builtin_open(outfile, '<STR_LIT:w>')<EOL>outf.close()<EOL>return<EOL><DEDENT>except IOError as e:<EOL><INDENT>cmsg = "<STR_LIT>".format(outfile)<EOL>if e.args:<EOL><INDENT>e.args = (e.args[<NUM_LIT:0>] + '<STR_LIT:\n>' + cmsg,) + e.args[<NUM_LIT:1>:]<EOL><DEDENT>else:<EOL><INDENT>e.args = (cmsg,)<EOL><DEDENT>raise e<EOL><DEDENT><DEDENT>prev_cs = self[<NUM_LIT:0>].coord_format<EOL>outf = None<EOL>try:<EOL><INDENT>outf = _builtin_open(outfile, '<STR_LIT:w>')<EOL>attr0 = self[<NUM_LIT:0>].attr[<NUM_LIT:1>]<EOL>defaultline = "<STR_LIT:U+0020>".join(["<STR_LIT>".format(a, attr0[a])<EOL>for a in attr0 if a != '<STR_LIT:text>'])<EOL>outf.write("<STR_LIT>".format(defaultline))<EOL>outf.write("<STR_LIT>".format(prev_cs))<EOL>for shape in self:<EOL><INDENT>shape_attr = '<STR_LIT>' if prev_cs == shape.coord_formatelse shape.coord_format + "<STR_LIT>"<EOL>shape_excl = '<STR_LIT:->' if shape.exclude else '<STR_LIT>'<EOL>text_coordlist = ["<STR_LIT>".format(f) for f in shape.coord_list]<EOL>shape_coords = "<STR_LIT:(>" + "<STR_LIT:U+002C>".join(text_coordlist) + "<STR_LIT:)>"<EOL>shape_comment = "<STR_LIT>" + shape.comment if shape.comment else '<STR_LIT>'<EOL>shape_str = (shape_attr + shape_excl + shape.name +<EOL>shape_coords + shape_comment)<EOL>outf.write("<STR_LIT>".format(shape_str))<EOL><DEDENT><DEDENT>except IOError as e:<EOL><INDENT>cmsg = "<STR_LIT>".format(outfile)<EOL>if e.args:<EOL><INDENT>e.args = (e.args[<NUM_LIT:0>] + '<STR_LIT:\n>' + cmsg,) + e.args[<NUM_LIT:1>:]<EOL><DEDENT>else:<EOL><INDENT>e.args = (cmsg,)<EOL><DEDENT>raise e<EOL><DEDENT>finally:<EOL><INDENT>if outf:<EOL><INDENT>outf.close()<EOL><DEDENT><DEDENT>
Write this shape list to a region file.

        Parameters
        ----------
        outfile : str
            File name