How to create new mi commands via python / get current interpreter in python

Simon Sobisch via Gdb
2021-11-02T16:41:10Z

It is possible to send `interpreter-exec mi "command"` from a python
extension, but how can we check the _current_ interpreter a python
create gdb command was executed in?

The reason: depending on the interpreter the return value should be
different

interpreter-exec console "break"
--> returns user output (which may be parsed)

vs.
interpreter-exec mi "-break-insert"
--> returns interpreter output intended to be parsed

Additional to this question: is there an option to create new MI
commands from python (instead of "console commands"), or python helper
functions which provide better ways to return mi-messages than plain
"print" with self-formatting?

Thanks for any insights,
Simon