def extract(self, offset, out=None):
        '''Extracts the tar item starting at offset to out'''
        if not 'r' == self.mode:
            raise ValueError, 'Cannot extract in append mode'
        assert offset % BLOCKSIZE == 0, 'Bad offset (%d)' % offset

        if out is None:
            return _pylibtar.pytar_extract_tobuf(self.tar, offset)
        else:
            if isinstance(out, basestring):
                fdout = open(out, 'w+b').fileno()
            elif hasattr(out, 'fileno'):
                fdout = out.fileno()
            else:
                fdout = out
            _pylibtar.pytar_extract(self.tar, offset, fdout)
            if hasattr(out, 'flush'):
                out.flush()
            return out
    def extract_iter(self, offset):
        '''Extracts the tar item starting at offset and returns an iterable'''
        if not 'r' == self.mode:
            raise ValueError, 'Cannot extract in append mode'
        assert offset % BLOCKSIZE == 0, 'Bad offset (%d)' % offset

        info = _pylibtar.pytar_info(self.tar, offset)
        if info['size'] <= self.CHUNKSIZE:
            yield _pylibtar.pytar_extract_tobuf(self.tar, offset)
        else:
            import tempfile
            tempfd, tempfn = tempfile.mkstemp()
            _pylibtar.pytar_extract(self.tar, offset, tempfd)
            os.close(tempfd)
            fh = open(tempfn, 'rb')
            os.unlink(tempfn)
            while 1:
                chunk = fh.read(self.CHUNKSIZE)
                if not chunk: break
                yield chunk