ptype.py 文件源码

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

项目:MacHeap 作者: blankwall 项目源码 文件源码
def append(self, object):
        """Add ``object`` to the ptype.container ``self``. Return the element's index.

        When adding ``object`` to ``self``, none of the offsets are updated and
        thus will need to be manually updated before committing to a provider.
        """

        # if we're uninitialized, then create an empty value and try again
        if self.value is None:
            self.value = []
            return self.append(object)

        # if object is not an instance, then try to resolve it to one and try again
        if not isinstance(object, generic):
            res = self.new(object)
            return self.append(res)

        # assume that object is now a ptype instance
        assert isinstance(object, generic), "container.append : {:s} : Tried to append unknown type to container : {:s}".format(self.instance(), object.__class__)
        object.parent,object.source = self,None

        current = len(self.value)
        self.value.append(object if object.initializedQ() else object.a)
        return current
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号