Parsing Binary Structures; Is there a better way / What is your way?
Martin P. Hellwig
martin.hellwig at dcuktec.org
Wed Aug 5 14:46:12 EDT 2009
Paul Rubin wrote:
> "Martin P. Hellwig" <martin.hellwig at dcuktec.org> writes:
>> what I usually do is read the packet in binary mode, convert the
>> output to a concatenated 'binary string'(i.e. '0101011000110') and
>
> Something wrong with reading the data words as an integer and using
> old fashioned shifts and masks to get at the bit fields?
No not at all of course, I just found it more readable to slice it
instead of shifting and masking; i.e. if the ASCII art schematics of the
protocol are included as a comment it is almost an 1 to 1 implementation.
Is there an advantage using shifts and masks over my kitchen type solution?
--
MPH
http://blog.dcuktec.com
'If consumed, best digested with added seasoning to own preference.'
More information about the Python-list
mailing list