def load_vars(path, vars):
    with open(path, 'rb') as f:
        # Load the variables from the cache.
        try:
            cache = pickle.load(f)
        except EOFError as e:
            cache={}
            #raise IOError(str(e))
        
        # Check that all requested variables could be loaded successfully
        # from the cache.
        missing_vars = sorted(set(vars) - set(cache.keys()))
        if missing_vars:
            raise ValueError(("The following variables could not be loaded "
                "from the cache: {0:s}").format(
                ', '.join(["'{0:s}'".format(var) for var in missing_vars])))
        additional_vars = sorted(set(cache.keys()) - set(vars))
        for hidden_variable in '_captured_io', '_cell_md5':
            try:
                additional_vars.remove(hidden_variable)
            except ValueError:
                pass
        if additional_vars:
            raise ValueError("The following variables were present in the cache, "
                    "but removed from the storage request: {0:s}".format(
                ', '.join(["'{0:s}'".format(var) for var in additional_vars])))
        
        return cache
Load variables from a pickle file.
dataset/ETHPy150Open rossant/ipycache/ipycache.py/load_vars