[Python-checkins] r46167 - sandbox/trunk/newstruct/newstruct.py

bob.ippolito python-checkins at python.org
Wed May 24 14:29:56 CEST 2006


Author: bob.ippolito
Date: Wed May 24 14:29:54 2006
New Revision: 46167

Modified:
   sandbox/trunk/newstruct/newstruct.py
Log:
unpack_from func

Modified: sandbox/trunk/newstruct/newstruct.py
==============================================================================
--- sandbox/trunk/newstruct/newstruct.py	(original)
+++ sandbox/trunk/newstruct/newstruct.py	Wed May 24 14:29:54 2006
@@ -73,4 +73,16 @@
     except KeyError:
         o = _compile(fmt)
     return o.unpack(s)
+
+def unpack_from(fmt, buffer, offset=0):
+    """
+    Unpack the buffer, containing packed C structure data, according
+    to fmt starting at offset.  Requires len(buffer[offset:]) >= calcsize(fmt).
+    See newstruct.__doc__ for more on format strings.
+    """
+    try:
+        o = _cache[fmt]
+    except KeyError:
+        o = _compile(fmt)
+    return o.unpack_from(buffer, offset)
     


More information about the Python-checkins mailing list