class OpCode: ONOFF = "w20" def sendCommand(opcode, args): with open("/dev/ttyUSB0", "w") as tty: print(f":{opcode}={args}.", end="\r\n", file=tty) sendCommand(OpCode.ONOFF, "1,0")