Dynamic repeat counts in struct format strings?
anthony at interlink.com.au
Tue Apr 29 06:18:12 CEST 2003
>>> "Francis Avila" wrote
> I suppose this message is just wondering aloud, but:
> Why hasn't the struct module grown a feature to specify the repeat count of
> an element based on the value of the previous element, like perl's
> What I mean is, why can't I do something like this (borrowing perl syntax of
> >>> struct.unpack('!h/s', '\x00\x05Hello')
I like this, but I have to wonder if something a bit more general
purpose would be better? What about the cases where the length isn't
immediately before the string? Why not instead have something like
the named groups in REs?
Anthony Baxter <anthony at interlink.com.au>
It's never too late to have a happy childhood.
More information about the Python-list