[Python-talk] struct pack
Lloyd Kvam
python at venix.com
Thu Aug 27 12:52:42 EDT 2009
On Thu, 2009-08-27 at 12:01 -0400, bruce.labitt at autoliv.com wrote:
> I did not understand the Section 8.3.1 Struct Objects.
> http://docs.python.org/library/struct.html
>
> Can someone provide a simple example (somewhat like above) that uses
> struct objects?
>
In [13]: from struct import Struct
In [14]: s = Struct(fmt)
In [15]: apackt = s.pack( *anum)
In [16]: apack = array( apackt)
Essentially the fmt is compiled once and reused with subsequent calls to
the Struct.pack method.
--
Lloyd Kvam
Venix Corp
DLSLUG/GNHLUG library
http://dlslug.org/library.html
http://www.librarything.com/catalog/dlslug
http://www.librarything.com/rsshtml/recent/dlslug
http://www.librarything.com/rss/recent/dlslug
More information about the Python-talk
mailing list