In the preceding recipe, we saw that there is a function equivalent to askopenfilename that returns a file object instead of a string, named askopenfile.
To save files, there is also a asksaveasfilename function that returns the path of the selected file. You can use this function if you want to modify the path or perform any validation before opening the file for writing.