I am new to python. I am tasked with creating a gui. The gui is fine but one of the buttons alters another python script. I have gotten the other script to open successfully. I do not want to open with 'w' because I need what is in it. 'a+' does not help becuase I need to change the code in the middle not at the end. Lastly, I am having difficulty with 'r+'. This is the code.
with open("test.py", "r+") as f
#f.seek(14)
#f.readline()
f.write('what is going on.\nI am very confused')
Readline always took it to the end of the other script. And I have 0 idea what seek did.
The actual file that will replace "test.py" will be 1000+ lines and I need to write on line 532. That is what I am asking how to do. There will be code on the line above and below 532 that I can not delete while adding a 8 line block.