Is there a way to extract all the codes in .tm and save them as a separate text file? For example consider the following test.tm document.
Now I want to extract all the codes in this
test.tm file in another text file (say test.py) which will contain all the code in the test.tm file, i.e., the .py file will contain:
def hello_world():
print("Hello World)
hello_world()
def print_numbers():
for i in range(1, 11):
print(i)
What would be the best way to achieve that in TeXmacs? Of course, the manual way would be creating a .py file and copying and pasting all code blocks from TeXmacs file, but for a .tm file with many code blocks this will be very tedious.

; Scheme programs are the most straightforward way to operate on TeXmacs documents. It is documented in part in the