This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: IDLE: Document SaveAs extension display on Mac
Type: behavior Stage: test needed
Components: IDLE Versions: Python 3.7, Python 3.6
Status: open Resolution:
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: ned.deily, rhettinger, taleinat, terry.reedy
Priority: normal Keywords:

Created on 2014-05-29 07:41 by rhettinger, last changed 2022-04-11 14:58 by admin.

Messages (11)
msg219338 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2014-05-29 07:41
In IDLE, edit and save a file
Then choose File SaveAs.
The dialog box only shows "foo", not ""
which is irritating when renaming a file or saving a variant of a file.
msg219355 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-05-29 18:33
There are known differences among the various Tk implementations with regard to how file extensions are handled in Tk file dialogs, like IDLE uses; see Issue4832.  Can you say which version of Tk was in use (it should be in the About IDLE display) and on what platform?  I was not able to reproduce this behavior on any of the current OS X IDLEs and Tks with Save As.
msg219424 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-05-30 19:58
On Win 7, I also see in the save dialog, both 2.7 and 3.4 as installed.
msg229117 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-10-12 05:53
I agree that having .py not visible but written would be obnoxious.  Hoever, without more information, I am inclined to close this as a 3rd parth (OS) issue.  Saimadhav, can you quickly try Save As with on Linux?
msg229128 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2014-10-12 07:59
> Can you say which version of Tk was in use 
> (it should be in the About IDLE display) and on what platform?

I am using ActiveTcl8.5.15.1 and a latest Python for Macs taken from the download page.  I'm running OS X 10.9.5.
msg229131 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-10-12 09:06
Thanks, Raymond.  Upon further investigation, I think you are running into a user-wide behavior of OS X rather than specifically a Tk or IDLE issue.  By tradition and by default, OS X tries to hide file extensions in file Open or Save dialogs; this dates back to the days of Classic Mac OS when there was no concept of file extensions.  There is a (non-obvious) user preference in the OS X Finder's preferences (Finder -> Preferences -> Advanced -> Show all filename extensions) that appears to control whether extensions are displayed by default in standard Open and Save dialogs in all applications, not just the Finder.  (This is with OS X 10.9.x; I believe recent earlier systems behave similarly although the details might be slightly different).  When the preference is unchecked (the default), then in "Save As" dialogs (in IDLE and other apps) a "Hide Extension" option box appears in the lower-left corner of the "Save As" popup window and, if enabled, the extension is not displayed as part of the file name.  Unchecking the "Hide Extension" box causes the extension to appear.  If the Finder "Show all filename extensions" advanced preference is checked, then the "Hide Extension" box does not appear on the "Save As" popup and the extension is always displayed.  I always have the "Show all filename extensions" preference checked so I forgot it was there and its effect on all file dialogs.  My guess is that you will want to have it enabled as well and then you should always see extensions.

Note that for the initial "Save" of a file in IDLE (as opposed to a "Save As"), Python 3.4 supplies a default extension of ".py" which is displayed regardless of the Finder preference setting; but Python 2.7 up through the current 2.7.8 does not supply the default.  That changes in 2.7.9 as Terry has recently backported the 3.x change to 2.7 (Issue4832, although the commit message for the backport appears in Issue3832 due to a typo).
msg229136 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-10-12 09:54
(I moved the commit message)

I am assuming that Ned is correct.  I think we should start documenting system peculiarities like this.  I changed the title and will leave this open for this purpose.
msg229178 - (view) Author: Saimadhav Heblikar (Saimadhav.Heblikar) * Date: 2014-10-12 17:06
>>Saimadhav, can you quickly try Save As with on Linux?

with files of type python: filename stored on disk ->
with all files type : filename stored on disk ->
msg229199 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-10-12 21:19
If Raymond concurs that either unchecking the Hide Extensions option or checking the Show All Filenmame Extensions preference solves the problem for him, we should just close this issue.  In this particular case, the file is actually saved with a .py extension; it's just that the extension part is not displayed in the standard OS file dialogs.  It is visible via, say, "ls" in a UNIX shell.  This is standard OS X application behavior and caters to two different styles of file interaction.  All OS X applications that use the standard file save dialogs work this way.  See, for example,
msg329656 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-11-11 01:29
I should have mentioned before, but forgot, that Windows, by default, hides file name extensions in File Explorer.  (The 'type' column supposedly makes them redundant.)  If they are hidden, they are also hidden in the Save As name box, as described for MacOS.  So I think this is worth a sentence in the doc.

After 4 years, I want to close this with or without an edit (for this and/or #4832).  The current SaveAs entry is

   Save the current window with a Save As dialog.  The file saved becomes the
   new associated file for the window.

(Ned has previously said leave this alone for both issues.)  Proposal:

Save the contents of the current window with a Save As dialog.  (If your file manager is set to hide extensions, the current extension will be omitted in the file name box.)  If the new filename has no '.', '.py' and '.txt' will be added for Python and text files.  (On MacOS Aqua, '.py' is added for any type.)  The file saved becomes the new associated file for the window.

msg329720 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2018-11-12 06:55
+1 for closing this either way, preferably with a note in the docs.

I'd add the notes about extensions in one set of parenthesis at the end, but that's likely just a matter of taste.
Date User Action Args
2022-04-11 14:58:04adminsetgithub: 65802
2018-11-12 06:55:45taleinatsetmessages: + msg329720
2018-11-11 01:29:17terry.reedysetnosy: + taleinat, - Saimadhav.Heblikar
messages: + msg329656
2017-06-30 00:48:37terry.reedysetassignee: terry.reedy
stage: test needed
versions: + Python 3.6, Python 3.7, - Python 2.7, Python 3.4, Python 3.5
2014-10-12 21:19:27ned.deilysetmessages: + msg229199
2014-10-12 17:06:42Saimadhav.Heblikarsetmessages: + msg229178
2014-10-12 09:54:10terry.reedysetmessages: + msg229136
title: IDLE SaveAs drops the extension in the prompted filename -> IDLE: Document SaveAs extension display on Mac
2014-10-12 09:06:14ned.deilysetmessages: + msg229131
2014-10-12 07:59:34rhettingersetmessages: + msg229128
2014-10-12 05:53:44terry.reedysetnosy: + Saimadhav.Heblikar
messages: + msg229117
2014-05-30 19:58:06terry.reedysetnosy: + terry.reedy
messages: + msg219424
2014-05-29 18:33:14ned.deilysetnosy: + ned.deily
messages: + msg219355
2014-05-29 07:41:12rhettingercreate