Fix up struct docstrings, add struct.pack_to function for symmetry
diff --git a/Lib/struct.py b/Lib/struct.py
index b4f56bb..51ee29a 100644
--- a/Lib/struct.py
+++ b/Lib/struct.py
@@ -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