Q:

Python program to write other programs

Could this be a possibility? Could you develop a program to write a program for you inside of the already existing program? Then save the program the program has written to a .py file and execute it as if it where the user?

A:

Any string in a python program can be run as a python script.
>>> python_script="print('hello autogenerated world')"
>>> exec(python_script)
hello autogenerated world

So you could generate a script as a string, save it to a file, the load it into a string and run it with exec . 
How to generate the script though, I think is a question that will require some knowledge of AI(neural networks)

