API Reference for Enthought Tool Suite 3.2.0
sstruct.py -- SuperStruct
Higher level layer on top of the struct module, enabling to bind names to struct elements. The interface is similar to struct, except the objects passed and returned are not tuples (or argument lists), but dictionaries or instances.
Just like struct, we use format strings to describe a data structure, except we use one line per element. Lines are separated by newlines or semi-colons. Each line contains either one of the special struct characters ('@', '=', '<', '>' or '!') or a 'name:formatchar' combo (eg. 'myFloat:f'). Repetitions, like the struct module offers them are not useful in this context, except for fixed length strings (eg. 'myInt:5h' is not allowed but 'myString:5s' is). The 'x' format character (pad byte) is treated as 'special', since it is by definition anonymous. Extra whitespace is allowed everywhere.
The sstruct module offers one feature that the "normal" struct module doesn't: support for fixed point numbers. These are spelled as "n.mF", where n is the number of bits before the point, and m the number of bits after the point. Fixed point numbers get converted to floats.
error = 'sstruct.error'
| Local name | Refers to |
|---|---|
| re | re |
| struct | struct |
| types | types |
© Copyright 2002-2009 Enthought, Inc.