I've made a function that will create functions and write them to a file but the problem is they write to the file as the default repr. How can I write them to a file as a normal function?
def make_route(title):
test = 1
def welcome():
return test + 1
welcome.__name__ = title
with open('test2.py', 'a') as f:
f.write('\n%s\n' % (welcome))
return welcome
I need it to write
def welcome():
return test + 1
to the file