In the never-ending quest to master Tkinter, I wrote a small version of Notepad.
Here is my "SaveAs" function:
def save_as(): if not mainw.filename: mainw.filename = tkFileDialog.asksaveasfilename(title="Save As...", filetypes=[("All Files","*.*"),("Text Files","*.txt")]) if not mainw.filename: return f = open(mainw.filename, "w") s = mainw.frame.edit.get("1.0",END) f.write(s) f.close()
As you can see, it dumps the entire contents of the text widget 'mainw.frame.edit' into a single string, and then writes it en masse to the file.
But suppose for some reason that the text file were War and Peace, or the OLE file documentation. Would that break Python?
In other words, should I manually manage memory here by getting smallish blocks and writing them, or can Python 'be smart' about my code?