diff options
author | Bob Ippolito <bob@redivi.com> | 2006-05-27 12:11:36 (GMT) |
---|---|---|
committer | Bob Ippolito <bob@redivi.com> | 2006-05-27 12:11:36 (GMT) |
commit | 1fcdc232dbfbd05b92eaed42bf9f779d27c55a92 (patch) | |
tree | 9ab05c5be55ea37cca7723725491bb80a8498a21 /Lib/struct.py | |
parent | 90bd0a554eec9d55b1474f713834681d2646ff25 (diff) | |
download | cpython-1fcdc232dbfbd05b92eaed42bf9f779d27c55a92.zip cpython-1fcdc232dbfbd05b92eaed42bf9f779d27c55a92.tar.gz cpython-1fcdc232dbfbd05b92eaed42bf9f779d27c55a92.tar.bz2 |
Fix up struct docstrings, add struct.pack_to function for symmetry
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 b4f56bb..51ee29a 100644 --- a/Lib/struct.py +++ b/Lib/struct.py @@ -62,6 +62,18 @@ def pack(fmt, *args): 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 |