diff options
Diffstat (limited to 'Lib/struct.py')
| -rw-r--r-- | Lib/struct.py | 12 | 
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/struct.py b/Lib/struct.py index ee5ddc2..648e39c 100644 --- a/Lib/struct.py +++ b/Lib/struct.py @@ -73,3 +73,15 @@ def unpack(fmt, s):      except KeyError:          o = _compile(fmt)      return o.unpack(s) +     +def unpack_from(fmt, buf, offset=0): +    """ +    Unpack the buffer, containing packed C structure data, according to +    fmt starting at offset. Requires len(buffer[offset:]) >= calcsize(fmt). +    See struct.__doc__ for more on format strings. +    """ +    try: +        o = _cache[fmt] +    except KeyError: +        o = _compile(fmt) +    return o.unpack_from(buf, offset)
\ No newline at end of file  | 
