_Node.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:seq2seq_parser 作者: trangham283 项目源码 文件源码
def attachChild(self, newChild, index = None):
        """
        Attach a (parentless) child. If the child has a parent
        already, call its reattach method
        """
        # Don't allow bidirectional parenthood
        assert not self is newChild
        if newChild.parent():
            raise AttachmentError('Cannot attach node: %s to: %s Node is already attached to %s' \
            % (newChild.prettyPrint(), self.prettyPrint(), newChild.parent().prettyPrint()))
        if index == None:
            if not self._children:
                self._children.append(newChild)
            else:
                bisect.insort_right(self._children, newChild)
        else:
            self._children.insert(index, newChild)
        newChild.setParent(self)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号