I'd like to know what to use to write a python script from another python script. When I will execute the 1st one, the 2nd one will be created with stuff I have in the first one.
Thank you.
I'd like to know what to use to write a python script from another python script. When I will execute the 1st one, the 2nd one will be created with stuff I have in the first one.
Thank you.
A python script is a normal plain text file. You can create it and write whatever you want into it exactly like you would do with a txt file.
One example is the following:
code = 'print "Hello world!"'
with open('my_script.py', 'w') as f:
f.write(code)
Now if you execute my_script.py, it will print "Hello world!"