You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IDLE does not supply a default ext of .py on Windows or OS X for new file saves #49082
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/terryjreedy'closed_at=<Date2014-10-06.04:30:11.962>created_at=<Date2009-01-04.15:16:01.578>labels= ['expert-IDLE', 'type-feature']
title='IDLE does not supply a default ext of .py on Windows or OS X for new file saves'updated_at=<Date2014-10-12.09:39:39.200>user='https://bugs.python.org/geon'
There should not be necessity to write filename *with extension* at the
saving dialog. It should be enough, at least on Windows, to put there
just "hello" and get "hello.py". It is really complication especially
for beginners. If they, as they are used to from another programs, put
there just "hello", it is saved without extension ".py" what have 2
result: they cannot see any icons at that file and they are not able to
run in, cause python.exe is bind with ".py".
Hoping its not duplicate I haven't found anything like this here.
I think I found the relevant documentation: http://wiki.tcl.tk/1842
"""
On Unix, when typing a filename without extension, the first extension
belonging to the currently selected filetype will be appended to the
filename. On Windows, this is not the case, but one can define a fixed
extension with the -defaultextension option. To get the same behaviour
on Unix, use -defaultextension {}.
"""
I tried to add "defaultextension=.py", (see attached patch) the problem
is that now it seems impossible to create a file without an extension...
devdanzin commented on May 13, 2009
devdanzinmannequin
Mannequin
More actions
Amaury,
Your patch also forces '.py' to any saved file on Linux, but using
'defaultextension = ""' it works correctly here. Does if fix things on
Windows?
geon commented on May 13, 2009
geonmannequin
MannequinAuthor
More actions
Trying to patch the latest revision 72608 and it didnt work, here on winxp.
C:\prg\Python30\Lib\idlelib>svn update
Restored 'IOBinding.py'
At revision 72608.
C:\prg\Python30\Lib\idlelib>patch IOBinding.py defaultextension.patch
--verbose
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Index: Lib/idlelib/IOBinding.py
|===================================================================
|--- Lib/idlelib/IOBinding.py (revision 72282)
|+++ Lib/idlelib/IOBinding.py (working copy)
--------------------------
Patching file IOBinding.py using Plan A...
Hunk #1 succeeded at 480 (offset -45 lines).
Hmm... Ignoring the trailing garbage.
done
If I do the patch by hand, it works. All files are saved with ext. .py.
When set 'defaultextension = ""', it is save well too, but then IDLE
crashed immediately.
gpolo commented on Aug 1, 2009
gpolomannequin
Mannequin
More actions
I'm attaching a very similar patch that I tested on Linux and Windows.
It just combines the default behaviour with the details required for
Windows, that is, the default extension is set to '.py' for Windows and
'' elsewhere (the default).
With this new patch, is it possible to create a file without extension
on Windows?
gpolo commented on Aug 4, 2009
gpolomannequin
Mannequin
More actions
With this new patch, is it possible to create a file without extension
on Windows?
It is tricky but, answering your question, you could enter a name
ending with a period to save without an extension.
It seems this isn't going anywhere then. The default behaviour on
Linux is to get the .py already, so this patch changes nothing there.
On Windows no extension is set by default, and with this patch it is
always .py if no extension is specified.
On Windows, I can't think of any common reason to want to save a file edited in IDLE without the .py extension. On the other hand, accidentally forgetting the .py extension is annoying, and users have come to expect a default extension being added by applications (e.g. MS Office).
Guilherme's patch (applied manually) works fine here on Windows7. I'm +1 for committing this if it has been tested to work as expected on Linux and OSX.
(minor nit-pick: could use sys.platform.startswith('win') instead of slicing)
I would forget about slicing or using startswith. "win32" is the platform name for Python on Windows whether or not it's 64-bit (see PC/pyconfig.h), so I'd just check """sys.platform == 'win32'"""
gpolo commented on Jul 20, 2010
gpolomannequin
Mannequin
More actions
Sorry but this is just bikeshedding, whoever commits can make this change or if it had been committed without this "improvement" then anyone could adjust without needing a new issue.
5 remaining items
serwy commented on Jul 10, 2012
serwymannequin
Mannequin
More actions
Your description applied to the behavior on Ubuntu 11.04.
As usual, there seem to be small but significant differences among the implementations. Testing with the three OS X Tk implementations shows that currently:
Aqua Tk 8.5 and Aqua Tk 8.4 do not supply a default extension
when saving. With patch bpo-4832.diff applied, they still incorrectly do not supply a default extension. (Note, Aqua Tk's do not supply a file type filter in the Save File dialog box.)
X11 Tk 8.5 behaves like other Unix X11 Tk's: a default based on the selected File Type filter is used, i.e. .py for "Python files, .txt for "Text file". Applying the patch does not change that correct behavior.
I tested a variation of Guilherme's patch which supplies a defaultextension of '.py' but only for OS X (rather than Windows). With that patch (issue4832_rev2.patch):
Aqua Tk 8.5 now correctly supplies a default extension of '.py' on saves if the user does not enter an extension as part of the file name.
Aqua Tk 8.4 behavior is unchanged: it still incorrectly does not supply an extension if the user does not. I don't see how to fix that but the use of Aqua Tk 8.4 is diminishing.
X11 Tk 8.5 behavior is unchanged: it still correctly supplies a default based on the selected File Type.
Since Aqua Tk 8.5 is the major Tk for OS X these days (it has been the system default since OS X 10.6) and the patch improves things for it, I'd like to see this go in. I did test it on a Debian Linux X11. It should behave the same on Windows as Roger's previous patch but it would be good to test it again.
As far as documentation changes, I don't see the need to have anything more than the usual IDLE/NEWS.txt file entry.
serwy commented on Jul 10, 2012
serwymannequin
Mannequin
More actions
I tried issue4832_rev2.patch on Ubuntu 11.04 with Tk 8.5 and it still behaves as Terry described.
Committed for 3.3. I'm +0.5 for 2.7 and 3.2. It seems like a bug to me. Terry, I'll leave it up to you to handle that and any further doc updates you want to make.
Better late than never. At least on Windows, with has defaultextension = '', changeing "Save as type" to "Text files" changes the default to ".txt". I presume that this bonus feature is not available on OSX, where defaultextension = '.py'. Before I update the doc (just before 2.7.9), can someone tell me what happens with linux, where defaultextension is '', as on Windows?
Thank you. It was in particular the switching between a -> a.py and a -> a.txt that I described and wanted verified for linux. The fact that names with extensions are left unchanged is important too. I will have to think about how to describe this succinctly.
Misdirected push message copied here.
New changeset 69cdf71bda12 by Terry Jan Reedy in branch '2.7':
Issue bpo-3832: backport 677a9326b4d4 to 2.7 (and delete some obsolete code). https://hg.python.org/cpython/rev/69cdf71bda12
Activity
geon commentedon Jan 4, 2009
There should not be necessity to write filename *with extension* at the
saving dialog. It should be enough, at least on Windows, to put there
just "hello" and get "hello.py". It is really complication especially
for beginners. If they, as they are used to from another programs, put
there just "hello", it is saved without extension ".py" what have 2
result: they cannot see any icons at that file and they are not able to
run in, cause python.exe is bind with ".py".
Hoping its not duplicate I haven't found anything like this here.
devdanzin commentedon Apr 26, 2009
I get the .py automatically on Linux, is this an intended behavior
difference or should this issue be considered a bug instead?
amauryfa commentedon May 13, 2009
I think I found the relevant documentation:
http://wiki.tcl.tk/1842
"""
On Unix, when typing a filename without extension, the first extension
belonging to the currently selected filetype will be appended to the
filename. On Windows, this is not the case, but one can define a fixed
extension with the -defaultextension option. To get the same behaviour
on Unix, use -defaultextension {}.
"""
I tried to add "defaultextension=.py", (see attached patch) the problem
is that now it seems impossible to create a file without an extension...
devdanzin commentedon May 13, 2009
Amaury,
Your patch also forces '.py' to any saved file on Linux, but using
'defaultextension = ""' it works correctly here. Does if fix things on
Windows?
geon commentedon May 13, 2009
Trying to patch the latest revision 72608 and it didnt work, here on winxp.
C:\prg\Python30\Lib\idlelib>svn update
Restored 'IOBinding.py'
At revision 72608.
C:\prg\Python30\Lib\idlelib>patch IOBinding.py defaultextension.patch
--verbose
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Index: Lib/idlelib/IOBinding.py
|===================================================================
|--- Lib/idlelib/IOBinding.py (revision 72282)
|+++ Lib/idlelib/IOBinding.py (working copy)
--------------------------
Patching file IOBinding.py using Plan A...
Hunk #1 succeeded at 480 (offset -45 lines).
Hmm... Ignoring the trailing garbage.
done
If I do the patch by hand, it works. All files are saved with ext. .py.
When set 'defaultextension = ""', it is save well too, but then IDLE
crashed immediately.
gpolo commentedon Aug 1, 2009
I'm attaching a very similar patch that I tested on Linux and Windows.
It just combines the default behaviour with the details required for
Windows, that is, the default extension is set to '.py' for Windows and
'' elsewhere (the default).
amauryfa commentedon Aug 4, 2009
With this new patch, is it possible to create a file without extension
on Windows?
gpolo commentedon Aug 4, 2009
It is tricky but, answering your question, you could enter a name
ending with a period to save without an extension.
It seems this isn't going anywhere then. The default behaviour on
Linux is to get the .py already, so this patch changes nothing there.
On Windows no extension is set by default, and with this patch it is
always .py if no extension is specified.
taleinat commentedon Jul 20, 2010
On Windows, I can't think of any common reason to want to save a file edited in IDLE without the .py extension. On the other hand, accidentally forgetting the .py extension is annoying, and users have come to expect a default extension being added by applications (e.g. MS Office).
Guilherme's patch (applied manually) works fine here on Windows7. I'm +1 for committing this if it has been tested to work as expected on Linux and OSX.
(minor nit-pick: could use sys.platform.startswith('win') instead of slicing)
briancurtin commentedon Jul 20, 2010
I would forget about slicing or using startswith. "win32" is the platform name for Python on Windows whether or not it's 64-bit (see PC/pyconfig.h), so I'd just check """sys.platform == 'win32'"""
gpolo commentedon Jul 20, 2010
Sorry but this is just bikeshedding, whoever commits can make this change or if it had been committed without this "improvement" then anyone could adjust without needing a new issue.
5 remaining items
serwy commentedon Jul 10, 2012
Your description applied to the behavior on Ubuntu 11.04.
ned-deily commentedon Jul 10, 2012
As usual, there seem to be small but significant differences among the implementations. Testing with the three OS X Tk implementations shows that currently:
when saving. With patch bpo-4832.diff applied, they still incorrectly do not supply a default extension. (Note, Aqua Tk's do not supply a file type filter in the Save File dialog box.)
I tested a variation of Guilherme's patch which supplies a defaultextension of '.py' but only for OS X (rather than Windows). With that patch (issue4832_rev2.patch):
Since Aqua Tk 8.5 is the major Tk for OS X these days (it has been the system default since OS X 10.6) and the patch improves things for it, I'd like to see this go in. I did test it on a Debian Linux X11. It should behave the same on Windows as Roger's previous patch but it would be good to test it again.
As far as documentation changes, I don't see the need to have anything more than the usual IDLE/NEWS.txt file entry.
serwy commentedon Jul 10, 2012
I tried issue4832_rev2.patch on Ubuntu 11.04 with Tk 8.5 and it still behaves as Terry described.
ned-deily commentedon Jul 13, 2012
Terry, are you planning to commit this? If not, I can do it. It would be good to get this into 3.3.0b2 since it does fix an important usability issue.
terryjreedy commentedon Jul 13, 2012
I agree. Go ahead. But what do you think of applying to 2.7 and or 3.2?
I want to add a sentence to Idle help, which I want to edit for the tooltips issue also. But that is not a rush.
python-dev commentedon Jul 13, 2012
New changeset 677a9326b4d4 by Ned Deily in branch 'default':
Issue bpo-4832: Modify IDLE to save files with .py extension by
http://hg.python.org/cpython/rev/677a9326b4d4
ned-deily commentedon Jul 13, 2012
Committed for 3.3. I'm +0.5 for 2.7 and 3.2. It seems like a bug to me. Terry, I'll leave it up to you to handle that and any further doc updates you want to make.
[-]idle filename extension[/-][+]IDLE does not supply a default ext of .py on Windows or OS X for new file saves[/+]terryjreedy commentedon Sep 10, 2013
With PEP-434, this can and I think should be backported. I should have done it for 2.7.5 and will try to do soon.
terryjreedy commentedon Oct 6, 2014
Better late than never. At least on Windows, with has defaultextension = '', changeing "Save as type" to "Text files" changes the default to ".txt". I presume that this bonus feature is not available on OSX, where defaultextension = '.py'. Before I update the doc (just before 2.7.9), can someone tell me what happens with linux, where defaultextension is '', as on Windows?
SaimadhavHeblikar commentedon Oct 6, 2014
I will try to describe the behavior on linux:
(Format used is "what i type in file name" -> "name which gets written to disk")
When files of type is: Python Files
a -> a.py
b.py -> b.py
c.py.py -> c.py.py
d.py.abc -> d.py.abc (!)
e.abc -> e.abc (!)
When files of type is: text file
Same behavior as before, with .txt instead of .py/.pyw
When files of type is: All files
a -> a
b.py -> b.py
c.py.py -> c.py.py
d.py.abc -> d.py.abc
e.abc -> e.abc
I hopefully have tried most of the combinations. If I have left out any, please let me know and I'll try them out.
terryjreedy commentedon Oct 6, 2014
Thank you. It was in particular the switching between a -> a.py and a -> a.txt that I described and wanted verified for linux. The fact that names with extensions are left unchanged is important too. I will have to think about how to describe this succinctly.
terryjreedy commentedon Oct 12, 2014
Misdirected push message copied here.
New changeset 69cdf71bda12 by Terry Jan Reedy in branch '2.7':
Issue bpo-3832: backport 677a9326b4d4 to 2.7 (and delete some obsolete code).
https://hg.python.org/cpython/rev/69cdf71bda12