Is this the efficent way?

Arinté shouldbe at message.com
Fri Jul 28 10:19:16 EDT 2000


I need to split a double (8) byte character into two bytes to send as a
string so I have this code
def hexSplit(arg):
 ans = 0
 lobyte =arg-256
 if arg<=255:
  ans = "\x00" + chr(arg)
 else:
  hibyte = lobyte/256
  if (lobyte%256)>0:
   hibyte = hibyte+1
  ans = chr(hibyte)+chr(lobyte)
 return ans


Is this good enough?

thanx





More information about the Python-list mailing list