descriptors.py 文件源码

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

项目:sqlalchemy-media 作者: pylover 项目源码 文件源码
def replace(self, attachable: [io.BytesIO, io.FileIO], position=None, **kwargs):
        """

        .. versionadded:: 0.5

        Replace the underlying file-object with a seekable one.

        :param attachable: A seekable file-object.
        :param position: Position of the new seekable file-object. if :data:`.None`, position will be preserved.
        :param kwargs: the same as the :class:`.BaseDescriptor`
        """

        if position is None:
            position = self.tell()
        # Close the old file-like object
        self.close()
        self._file = attachable

        # Some hacks are here:
        super().__init__(**kwargs)
        self.seek(position)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号