[Python-ideas] Suggest adding struct iter_unpack allowing mixed formats & add iter_pack

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Jan 30 16:18:59 EST 2018


Steve Barnes wrote:
> It would be very nice if:
>    a) iter_unpack.next produced an iterator that optionally took an 
> additional parameter of a format string, (with endianness permitted), to 
> replace the current format string in use.

Hmmm, rather than screw around with the iterator
protocol, it might be better to design a separate
api for this. Maybe a pair of functions:

    struct.read(stream, format)
    struct.write(stream, format, data)

-- 
Greg


More information about the Python-ideas mailing list