I am trying to write a procedure that will automate the procedure of making a tkinter window, so I am trying to use the open() function to open a txt file (probably should be a .py shouldn’t it?) that a procedure that makes the window, the code I am trying to have it write is:
def a_procedure():
window = Tk()
#rest of code necessary to make a Tkinter window
but the problem is, when I use
open()
textfile.write("def a_procedure()"/
"window = Tk()")
what I get in the text file is: def a_procedure(): window = TK() #rest of text
Is there (a)A way to write multiple lines with
open()
or (b)A better way to write a procedure with a procedure
You can use multi-line strings:
Just make sure to keep stuff indented properly.
Why do you need to generate Python from a Python script?