def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING,<EOL>prettyPrint=False, indentLevel=<NUM_LIT:0>):
encodedName = self.toEncoding(self.name, encoding)<EOL>attrs = []<EOL>if self.attrs:<EOL><INDENT>for key, val in self.attrs:<EOL><INDENT>fmt = '<STR_LIT>'<EOL>if isString(val):<EOL><INDENT>if self.containsSubstitutions and '<STR_LIT>' in val:<EOL><INDENT>val = self.substituteEncoding(val, encoding)<EOL><DEDENT>if '<STR_LIT:">' in val:<EOL><INDENT>fmt = "<STR_LIT>"<EOL>if "<STR_LIT:'>" in val:<EOL><INDENT>val = val.replace("<STR_LIT:'>", "<STR_LIT>")<EOL><DEDENT><DEDENT>val = self.BARE_AMPERSAND_OR_BRACKET.sub(self._sub_entity, val)<EOL><DEDENT>attrs.append(fmt % (self.toEncoding(key, encoding),<EOL>self.toEncoding(val, encoding)))<EOL><DEDENT><DEDENT>close = '<STR_LIT>'<EOL>closeTag = '<STR_LIT>'<EOL>if self.isSelfClosing:<EOL><INDENT>close = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>closeTag = '<STR_LIT>' % encodedName<EOL><DEDENT>indentTag, indentContents = <NUM_LIT:0>, <NUM_LIT:0><EOL>if prettyPrint:<EOL><INDENT>indentTag = indentLevel<EOL>space = ('<STR_LIT:U+0020>' * (indentTag-<NUM_LIT:1>))<EOL>indentContents = indentTag + <NUM_LIT:1><EOL><DEDENT>contents = self.renderContents(encoding, prettyPrint, indentContents)<EOL>if self.hidden:<EOL><INDENT>s = contents<EOL><DEDENT>else:<EOL><INDENT>s = []<EOL>attributeString = '<STR_LIT>'<EOL>if attrs:<EOL><INDENT>attributeString = '<STR_LIT:U+0020>' + '<STR_LIT:U+0020>'.join(attrs)<EOL><DEDENT>if prettyPrint:<EOL><INDENT>s.append(space)<EOL><DEDENT>s.append('<STR_LIT>' % (encodedName, attributeString, close))<EOL>if prettyPrint:<EOL><INDENT>s.append("<STR_LIT:\n>")<EOL><DEDENT>s.append(contents)<EOL>if prettyPrint and contents and contents[-<NUM_LIT:1>] != "<STR_LIT:\n>":<EOL><INDENT>s.append("<STR_LIT:\n>")<EOL><DEDENT>if prettyPrint and closeTag:<EOL><INDENT>s.append(space)<EOL><DEDENT>s.append(closeTag)<EOL>if prettyPrint and closeTag and self.nextSibling:<EOL><INDENT>s.append("<STR_LIT:\n>")<EOL><DEDENT>s = '<STR_LIT>'.join(s)<EOL><DEDENT>return s<EOL>
Returns a string or Unicode representation of this tag and
        its contents. To get Unicode, pass None for encoding.

        NOTE: since Python's HTML parser consumes whitespace, this
        method is not certain to reproduce the whitespace present in
        the original string.