File: tst_bytes.py

package info (click to toggle)
pyotherside 1.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 880 kB
  • sloc: cpp: 2,869; python: 475; makefile: 152; sh: 35
file content (10 lines) | stat: -rw-r--r-- 319 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
import struct

def get_bytes():
    return struct.pack('<bhi', 123, 456, 789)

def set_bytes(bytedata):
    print('Got this raw data from QML:', bytedata)
    a, b, c = struct.unpack('<hhI', bytedata)
    print('Got this data (unpacked) from QML:', a, b, hex(c))
    return a == 1337 and b == -4711 and c == 0xcafebabe