Мне не совсем понятно, что именно вы ищете, но вот предположение:
def format1(opline, string):
print('format1({!r}, {!r})'.format(opline, string))
opline = opline.split(' ', 1)[1]
rd, rs, rt = opline.split()
return rd, rs, rt
def format2(opline, string):
print('format2({!r}, {!r})'.format(opline, string))
opline = opline.split(' ', 1)[1]
rd, rs, rt = opline.split()
return rd, rs, rt
inst_match = {'add': format1,
'sub': format2}
instruction_storage = [('add 9 0 255', 'string1'),
('sub 10 1 127', 'string2')]
for instruction in instruction_storage:
opline, string = instruction
opcode = opline.split()[0]
try:
inst_match[opcode](opline, string)
except KeyError:
print('unknown instruction: {!r}'.format(opcode))
Вывод:
format1('add 9 0 255', 'string1')
format2('sub 10 1 127', 'string2')