def _unpack_septets(seq, padding=0):
 (msgbytes, r) = _consume_bytes(seq, (len(seq) / 2))
 msgbytes.reverse()
 asbinary = ''.join(map(_to_binary, msgbytes))
 if (padding != 0):
  asbinary = asbinary[:(- padding)]
 chars = []
 while (len(asbinary) >= 7):
  chars.append(int(asbinary[(-7):], 2))
  asbinary = asbinary[:(-7)]
 return ''.join(map(chr, chars))

def _unpack_septets ( seq , padding = 0 ) : ( msgbytes , r ) = _consume_bytes ( seq , ( len ( seq ) / 2 ) ) msgbytes . reverse ( ) asbinary = '' . join ( map ( _to_binary , msgbytes ) ) if ( padding != 0 ) : asbinary = asbinary [ : ( - padding ) ] chars = [ ] while ( len ( asbinary ) >= 7 ) : chars . append ( int ( asbinary [ ( - 7 ) : ] , 2 ) ) asbinary = asbinary [ : ( - 7 ) ] return '' . join ( map ( chr , chars ) )
this function taken from: URL thank you adam sampson <ats@offog .