Message290501
For the native alignment case (prefix code @), perhaps you can already use the “ctypes” module, which supports structures with more complicated embedded fields.
For the the unaligned modes (prefixes =, <, > and !), I am a little sympathetic. In the past, I wanted to make various structures that extended from a common base structure:
HSF_VOL_DESC = Struct("< B 5s B")
# Python 3's "Struct.format" is a byte string!
NSR_DESC = Struct(HSF_VOL_DESC.format.decode() + "B")
But I think if Issue 21071 was fixed (change Struct.format to text string, or perhaps add a new attribute), I would be happy enough writing
NSR_DESC = Struct(HSF_VOL_DESC.format_str + "B")
Transforming Aviv’s examples:
s3 = Struct(s1.format_str + s2.format_str[1:])
s3 = Struct(s1.format_str + "B") # if s2 is not needed on its own
ver2 = Struct(ver1.format_str + "I")
version_a = Struct(start.format_str + union_b.format_str[1:]) |
|
Date |
User |
Action |
Args |
2017-03-25 21:32:25 | martin.panter | set | recipients:
+ martin.panter, rhettinger, mark.dickinson, meador.inge, serhiy.storchaka, palaviv |
2017-03-25 21:32:25 | martin.panter | set | messageid: <1490477545.48.0.763742890768.issue29903@psf.upfronthosting.co.za> |
2017-03-25 21:32:25 | martin.panter | link | issue29903 messages |
2017-03-25 21:32:25 | martin.panter | create | |
|