Struct class random access

castironpi castironpi at gmail.com
Mon Aug 25 16:03:09 EDT 2008


struct.Struct lets you encode Python objects into structured memory.
It accepts a format string, and optionally a buffer and offset to/from
which to read/write the structure.  What do you think of random access
for the results?

(unproduced)
>>> packer= struct.Struct( 'IIIf255p' )
>>> packer.pack_into( buf, off, 10, 20, 30, 0.5, 'abc' )
>>> packer.unpack_from( buf, off, 2 ) #reads field 2
30

Does this take a PEP, or just a patch submission?



More information about the Python-list mailing list