Construct 1.20 released

tomerfiliba at tomerfiliba at
Fri Apr 7 16:10:11 CEST 2006

what is Construct? Construct is a library for declaratively defining
data structures at the bit-level, with lots of "built-in" constructs.


note: the code is getting pretty stable already, so dont expect any
more frequent releases.

what's new?
* added Formatted, a construct that uses the built-in struct module.
* added [Big/Little]Float[32/64], both parsing and building, using
* added FlagsAdapter (see example below)
* improved Flag, the constructor now takes 'inverted' instead of
* improved LV, and made PascalString use LV instead
* removed PascalStringAdapter
* removed the utils package (may be re-added later if i find what to
put in it)

say you have a 32-bit integer that holds flags, but splitting it up to
a Struct of Flag's is difficult,
because of byte-ordering, etc. the new FlagsAdapter lets you do the

my_flag = FlagsAdapter(
        owner_read = 0x0001,
        owner_write = 0x0002,
        owner_execute = 0x0004,
        group_read = 0x0008,
        group_write = 0x0010,
        group_execute = 0x0020,
        other_read = 0x0040,
        other_write = 0x0080,
        other_execute = 0x0100,

>>> print my_flag.parse("\x83\x00\x00\x00")
    group_execute = False
    group_read = False
    group_write = False
    other_execute = False
    other_read = False
    other_write = True
    owner_execute = False
    owner_read = True
    owner_write = True


More information about the Python-announce-list mailing list