struct: type registration?

Serge Orlov Serge.Orlov at gmail.com
Thu Jun 1 20:18:46 CEST 2006


Giovanni Bajo wrote:
> John Machin wrote:
> > I am an idiot, so please be gentle with me: I don't understand why you
> > are using struct.pack at all:
>
> Because I want to be able to parse largest chunks of binary datas with custom
> formatting. Did you miss the whole point of my message:
>
> struct.unpack("3liiSiiShh", data)

Did you want to write struct.unpack("Sheesh", data) ? Seriously, the
main problem of struct is that it uses ad-hoc abbreviations for
relatively rarely[1] used functions calls and that makes it hard to
read.

If you want to parse binary data use pyconstruct
<http://pyconstruct.wikispaces.com/>

[1] Relatively to regular expression and string formatting calls.




More information about the Python-list mailing list