[Python-Dev] proposed struct module format code addition

Carlos Ribeiro carribeiro at gmail.com
Sun Oct 3 22:52:12 CEST 2004


On Sun, 03 Oct 2004 13:28:30 -0600, Shane Holloway (IEEE)
<shane.holloway at ieee.org> wrote:
> One of the greatest things I use struct is for is packing (and
> unpacking) the python building blocks for "external use" -- network,
> database, and (usually C) libraries.  I think it would be best if all
> the building blocks could be packed and unpacked from one module.
> 
> The additions to binascii would be more convenient to use of the two
> additions.  But truth to tell, I rarely use binascii.  I tend to prefer
> struct.pack with str.encode.
> 
> What do you think about adding long.tobytes()/long.frombytes() to go
> with the new bytes() type?  <wink>

Sorry for introducing my not-very-qualified words on this topic,
but... I've read the thread up to this point wondering why the bytes()
type were not being thought of as a clean and definitive solution to
this problem. It would allow to greatly simplify everything regarding
struct, binascii and arbitrary low level data manipulation for
networking and similar stuff.

I also agree with Tim Peters comments regarding struct's C heritage --
I never really liked C even when I *had* to use it daily, and the
struct syntax still reads alien to me. I know this is another
timeframe entirely, but *if* my vote counted, I would be +1 for a
future struct implementation tightly integrated with the bytes() type.
But that's me anyway.

-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com


More information about the Python-Dev mailing list