All pastes #78714 Raw Edit

Miscellany

public python v1 · immutable
·published 2006-07-04 13:47 UTC
rendered paste body
        f = file(fn)        data = dict.fromkeys(data_keys, None)        boundaries = []        # read boundaries        while True:            line = f.readline()            boundaries.append(int(line.strip()))            if not line or len(boundaries) == len(data_keys):                    break        # read data        for idx, data_length in enumerate(boundaries):            key = data_keys[idx]            tmp = f.read(data_length)            data[key] = tmp        f.close()