Mercurial > cpython-lru_cache-weakref
diff Lib/struct.py @ 38430:795d1cb1df01 legacy-trunk
Fix up struct docstrings, add struct.pack_to function for symmetry
| author | Bob Ippolito <bob@redivi.com> |
|---|---|
| date | Sat, 27 May 2006 12:11:36 +0000 |
| parents | b2491fd0a4dc |
| children | a114003aa3d3 |
line wrap: on
line diff
--- a/Lib/struct.py Sat May 27 11:47:12 2006 +0000 +++ b/Lib/struct.py Sat May 27 12:11:36 2006 +0000 @@ -62,6 +62,18 @@ o = _compile(fmt) return o.pack(*args) +def pack_to(fmt, buf, offset, *args): + """ + Pack the values v2, v2, ... according to fmt, write + the packed bytes into the writable buffer buf starting at offset. + See struct.__doc__ for more on format strings. + """ + try: + o = _cache[fmt] + except KeyError: + o = _compile(fmt) + return o.pack_to(buf, offset, *args) + def unpack(fmt, s): """ Unpack the string, containing packed C structure data, according
