New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IDLE does not supply a default ext of .py on Windows or OS X for new file saves #49082
Comments
There should not be necessity to write filename *with extension* at the Hoping its not duplicate I haven't found anything like this here. |
I get the .py automatically on Linux, is this an intended behavior |
I think I found the relevant documentation: I tried to add "defaultextension=.py", (see attached patch) the problem |
Amaury, |
Trying to patch the latest revision 72608 and it didnt work, here on winxp. C:\prg\Python30\Lib\idlelib>svn update C:\prg\Python30\Lib\idlelib>patch IOBinding.py defaultextension.patch If I do the patch by hand, it works. All files are saved with ext. .py. |
I'm attaching a very similar patch that I tested on Linux and Windows. |
With this new patch, is it possible to create a file without extension |
It is tricky but, answering your question, you could enter a name It seems this isn't going anywhere then. The default behaviour on |
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'""" |
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. |
The behavior (for Windows) I expect and would like is that the default extension would be .py, .txt, or nothing, depending on the selection in the 'save as type' box in the SaveAS dialog. (.pyw, being rare, would have to be explicitly typed.) Of course, doubled extensions like .py.py should be avoided. I believe other apps on Windows do something like this, but I should check. I have no idea how the other systems differ. |
I was unable to produce the crash that Pavel described in msg87703. Just adding "defaultextension=''" solves this issue for Windows and still preserves the correct behavior on Linux. Amaury's quote of tcl/tk documentation in msg87695 mentions this as well. I tested this on Linux with 2.7.1 and 3.2 and on Windows Vista using 2.7.1 and 3.2.2. Attached is a diff against 3.3a0. |
issue4832_rev1.patch is a complete patch against 3.3. This is also part of bpo-13504, "7) ANNOYANCE: It’s too easy to forget the .py extension when saving a file." |
I tested with defaultextension='' on Windows and it works well. If no extension is entered (no '.' in name), .py or .txt is added for the .py/w and .txt filetype choices. If there is a . in the name, nothing is added. If one wants x.y.py, one must type the whole name. So typing x.pyw does not get .py added on top of it. This needs to be documented in the Idle help file. Should the change only be made to 3.3, or also to 3.2/2.7? The old behavior of typing .py still works, so that does not break. Typing no . to get no extension (rare) will break unless one selects '*.* all files' (which one should do anyway as it is standard Windows behavior). I think uniform across versions is better so people who learn leaving out .py on 3.3 can also leave it out in future 2.7 and 3.2, which should come out about the same time as 3.3.0. Whether just one or two or three versions, how do people used to the old (buggy in my opinion) behavior find out about the change. A splash line on startup "See help for new 'save as' behavior" ? Anything I should know about *nix or mac behavior, at least for the doc? Ned, does this change work on macs? |
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:
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. |
I tried issue4832_rev2.patch on Ubuntu 11.04 with Tk 8.5 and it still behaves as Terry described. |
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. |
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. |
New changeset 677a9326b4d4 by Ned Deily in branch 'default': |
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. |
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. |
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? |
I will try to describe the behavior on linux: (Format used is "what i type in file name" -> "name which gets written to disk")
I hopefully have tried most of the combinations. If I have left out any, please let me know and I'll try them out. |
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. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: