The struct module can help you create a buffer of the right length and initialize it with appropriate data, for details see Programmer’s Python: Everything is Data, ISBN:9781871962595. There are many ...
Putting all this together, including definitions for unused constants, gives: import fcntl import struct import io GPIO_GET_CHIPINFO_IOCTL = 0x8044B401 GPIO_GET_LINEHANDLE_IOCTL = 0xC16CB403 ...