classification
Title: Idle: saving Shell or an OutputWindow should default to .txt
Type: behavior Stage: patch review
Components: IDLE Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: Saimadhav.Heblikar, rhettinger, terry.reedy
Priority: normal Keywords: patch

Created on 2014-04-03 02:47 by terry.reedy, last changed 2021-09-27 06:07 by terry.reedy.

Files
File name Uploaded Description Edit
issue21140-27.patch Saimadhav.Heblikar, 2014-04-03 16:02 review
issue21140-34.patch Saimadhav.Heblikar, 2014-04-03 16:03 review
Messages (9)
msg215419 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-04-03 02:47
If possible, when saving an instance of an OutputWindow, the file type should default to .txt (or possibly even nothing) instead of .py. At present, OutputWindows are only used for Find in Files (grep) output, which is very much not Python code. The same should be true of any other OutputWindow uses, which I except there will be, making OutputWindow saves more common.

A patch should be tested and verified on Mac, Linux, and Windows.
msg215454 - (view) Author: Saimadhav Heblikar (Saimadhav.Heblikar) * Date: 2014-04-03 16:02
Attaching a patch.
The file type on OutputWIndow defaults to .txt. Can be very easily made to default to none aswell.

Tested on linux for 2.7 and 3.4.(Debian Wheezy, Gnome 3)


On 2.7, made changes so that ispythonsource(in EditorWindow) behaves similar to 3.4(in EditorWindow)

On both 2.7 and 3.4, made change to ispythonsource(in OutputWindow), to make it return False instead of 0(to mirror behavior in EditorWindow)
msg215485 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2014-04-04 03:09
FWIW, students commonly save shell sessions as a record of everything they tried in call.  It would nice if there were a way to trigger a periodic autosave (perhaps every five minutes or so).
msg215500 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-04-04 08:15
Raymond, I open #21152 with your idea. #11838 and #19042 are somewhat related but timed autosave is not a part of either.
msg260207 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-02-12 22:28
In #11830 I suggested that Shell should be added to this issue. #26327 does the same, as the prompt and output are not code.

At least in 3.x, these mixed code and text files should be encoded utf-8 (which is the same as ascii for all ascii files), as code files are (at least by default).  The encoding search and determination in IDBinding.py is a bit baroque.  The local encoding should not ever be used for 3.x code.

If we do something with #11838 (save runnable code from Shell), the default should then revert to .py.  I don't want a patch here to make this excessively difficult.
msg278169 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-10-06 04:19
I am closing #28365 in favor of this.  As noted there, Shell is a subclass of OutputWindow is a subclass of EditorWindow, so Shell should inherit new behavior from OutputWindow instead of both from EW.

Change to the patch: I think .py should not even be a selectable option as Shell cannot be edited down to code, and it would make no sense to do so.  And anyone who did want to save as .py could select 'all types' and type '.py' explicitly.

I was thinking that filetype should be set in OutputWindow, but that does not include text files in an editor window (with editwin.ispythonsource(self.filename) False).  Another reason is that I want to change the editor class structure.

Currently. the editor window used for all files is the confusingly named PyShellEditorWindow in pyshell.py, which adds breakpoints to EditorWindow.  In long run, EditorWindow should be used for non-python editing.  The current PyShellEditorWindow should become PythonEditor and have all the attributes and methods specific to python code.  Then EditorWindow.filetypes would have .txt and *.* and .py would be added in PythonEditor.  It would also, then, not be necessary to disable code stuff in OutputWindow (like the Run menu).  (In fact, it might turn out that EditorWindow and OutputWindow would be the same, a base TextEditor
msg278209 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-10-06 20:16
A more drastic change would be to refuse to save OutputWindow and Shell as .py(w,o) files.  #28365 is about a beginner who apparently save a short Shell session as .py, quit IDLE, loaded the saved session in an editor, and tried to run it.
msg370850 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-06-06 19:43
There was a recent stackoverflow question in which newbie pulled shell log into editor and ran as is.  Got SyntaxError as 'Python 3' start of startup message.
msg402692 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-09-27 06:07
From #45297, closed as duplicate.
https://discuss.python.org/t/what-is-this-syntax-i-dont-know-how-to-fix-it/10844
History
Date User Action Args
2021-09-27 06:07:06terry.reedysetmessages: + msg402692
2020-06-06 19:43:04terry.reedysetmessages: + msg370850
versions: + Python 3.10, - Python 3.6, Python 3.7
2016-10-06 20:24:56terry.reedylinkissue28365 superseder
2016-10-06 20:16:29terry.reedysetmessages: + msg278209
2016-10-06 04:19:40terry.reedysetassignee: terry.reedy
stage: needs patch -> patch review
messages: + msg278169
versions: + Python 3.6, Python 3.7, - Python 2.7, Python 3.4, Python 3.5
2016-02-12 22:28:51terry.reedysetmessages: + msg260207
title: Idle: saving an OutputWindow should default to .txt -> Idle: saving Shell or an OutputWindow should default to .txt
2014-04-04 08:15:24terry.reedysetmessages: + msg215500
2014-04-04 03:09:05rhettingersetnosy: + rhettinger
messages: + msg215485
2014-04-03 16:03:06Saimadhav.Heblikarsetfiles: + issue21140-34.patch
2014-04-03 16:02:55Saimadhav.Heblikarsetfiles: + issue21140-27.patch
keywords: + patch
messages: + msg215454
2014-04-03 11:53:07Saimadhav.Heblikarsetnosy: + Saimadhav.Heblikar
2014-04-03 02:47:39terry.reedycreate