python Tkinter tkFileDialog
<p>in short, what's the difference between</p>

<pre><code>tkFileDialog.asksaveasfile
</code></pre>

<p>and</p>

<pre><code>tkFileDialog.asksaveasfilename
</code></pre>

<p>I could not understand from the build in docs</p>

<p><code>asksaveasfile</code> asks the user for a file, then opens that file in write mode and returns it to you so you can write in it.</p>

<p><code>asksaveasfilename</code> asks the user for a file, then returns that file's name. No file is opened; if you want to write to the file, you'll have to open it yourself.</p>

<p><code>asksaveasfilename</code> might be preferred over <code>asksaveasfile</code> if you want to do something fancier to the file than just writing data to it. For instance, you might want to first copy the file to another directory as a backup. In which case, you'd prefer to get just the file name so you can perform the copy without having to worry about whether having the file open will cause the copy to fail.</p>

python tkinter