pythonic malloc
kjockey
kj at ockey.fake.
Mon Jul 21 05:15:26 EDT 2003
More information about the Python-list mailing list
Mon Jul 21 05:15:26 EDT 2003
- Previous message (by thread): listening com ports
- Next message (by thread): pythonic malloc
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I have some simple UDP code that does:
s.sendto("\xf0\x00\x02\x00rachel\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",addr)
This is OK, except that I'd like to change the text in the middle ("rachel",
which is the hostname FWIW), and the NUL padding needs to go out to make
the length 25 bytes (so the padding depends on the length of the name).
So I could do something like:
retpacket = "\xf0\x00\x02\x00"+socket.gethostname()
while len(retpacket) < 26:
retpacket += "\x00"
s.sendto(retpacket, addr)
But that feels "wrong". And Python in a Nutshell says its a bad idea -
"anti-idiom".
Can anyone show me the true path?
Brad
- Previous message (by thread): listening com ports
- Next message (by thread): pythonic malloc
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list