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.
Created on 2016年10月05日 15:35 by radialbeast, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| 2016年10月06日 (4).png | radialbeast, 2016年10月06日 17:15 | |||
| Messages (9) | |||
|---|---|---|---|
| msg278132 - (view) | Author: A.J. (radialbeast) | Date: 2016年10月05日 15:35 | |
whenever I go to run a program no matter what I do it always says syntax error and highlights the 5 in the 3.5.2 version banner |
|||
| msg278134 - (view) | Author: Zachary Ware (zach.ware) * (Python committer) | Date: 2016年10月05日 15:45 | |
Hi A.J., What you're describing isn't really possible, so you're going to need to provide some more detail. Please copy and paste your Command Prompt session into a message here to show us what's going on. |
|||
| msg278135 - (view) | Author: Tim Golden (tim.golden) * (Python committer) | Date: 2016年10月05日 15:47 | |
This sometimes happens when someone copies from a book or a tutorial and includes as though code the banner header which is only meant to illustrate the context. |
|||
| msg278138 - (view) | Author: Steven D'Aprano (steven.daprano) * (Python committer) | Date: 2016年10月05日 17:05 | |
See #28366 |
|||
| msg278141 - (view) | Author: Paul Moore (paul.moore) * (Python committer) | Date: 2016年10月05日 17:25 | |
I can recreate this (based on the screenshots from #28366). To reproduce, open IDLE. You get the console banner and prompt. Save that file using File-Save. The close IDLE. Reopen it, do File-Open to open your saved console session, then use the "Run" menu to run it. (You need to close IDLE, so it "forgets" the .py file came from a console session.) That's incorrect usage, of course (not "of course" to the OP - that's the real point here) as the text of a console session isn't a valid Python file, and doesn't syntax check. The error is saying precisely that - what is in the file isn't valid Python. So in one sense, this is simply user error. But I wonder, is there something about how IDLE presents things that could be improved? Either in the documentation or in the UI? I'm not exactly sure what the point of "file-save" in a console window is, and certainly it would be better to save the transcript as text so it couldn't be inadvertently be read back in as a Python module. I'm not an IDLE user, though, so I don't really have the background to know the best solution. |
|||
| msg278142 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2016年10月05日 17:51 | |
I'm retitling the issue. The new title doesn't necessary represent the "bug" that needs to be fixed, but it does seem to represent the *apparent* error. |
|||
| msg278198 - (view) | Author: A.J. (radialbeast) | Date: 2016年10月06日 17:15 | |
There is no other way to explain it without fail every time no matter what code I write there is always syntax error highlighted on the five in the version banner. |
|||
| msg278210 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2016年10月06日 20:24 | |
I am closing this as a duplicate of existing #21140, to make .txt instead of .py the extension for files known not to be code files. I There is an existing simple patch. I will modify it to not even offer .py as a secondary choice. The reason Paul had to close IDLE to open the file in an(other) editor window is that Python allows only one editor window per file, and Shell is a subclass of OutputWindow, which is a subclass of EditorWindow. (The latter inheritance is backwards; OutputWindow should be the base TextEditor and 'CodeEditor' a subclass thereof.) When Shell is saved, the file name appears on the recent files list, and attempts to open it make the exiting editor the active window. Angie, as Paul explained, your screenshot shows a text file, mislabeled as a .py python file, in the editor. When you run non-code text as code, you get a SyntaxError. The text file appears to be a saved interactive shell session. "Python 3" by itself is a SyntaxError and will continue to be an error no matter what follows. It is possible that your Python installation, or the IDLE part of it, is badly broken, and needs to be repaired or re-installed. But I think it much much more likely that you have made a mistake. If you want to discuss this further, please post to python-list (or its news.gmane.org mirror). Include a link to this issue, give a detailed description of what you did (keystrokes and mouse clicks), and ask any questions. |
|||
| msg278211 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2016年10月06日 20:31 | |
PS. A.J., you will likely be a happier user if you make a subdirectory under c:/Users/angie and put your files there instead of in the installation directory under the hidden AppDate |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:37 | admin | set | github: 72551 |
| 2016年10月06日 20:31:24 | terry.reedy | set | messages: + msg278211 |
| 2016年10月06日 20:24:56 | terry.reedy | set | status: open -> closed title: idle forgets that saved console session is not a python file after restart -> IDLE: don't offer to save text files as .py superseder: Idle: saving Shell or an OutputWindow should default to .txt messages: + msg278210 resolution: duplicate stage: resolved |
| 2016年10月06日 17:15:51 | radialbeast | set | files:
+ 2016年10月06日 (4).png messages: + msg278198 |
| 2016年10月05日 18:40:45 | zach.ware | set | assignee: terry.reedy components: + IDLE, - Windows |
| 2016年10月05日 17:51:21 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg278142 title: 3.5.2 syntax issue -> idle forgets that saved console session is not a python file after restart |
| 2016年10月05日 17:47:53 | steven.daprano | set | nosy:
+ terry.reedy |
| 2016年10月05日 17:25:59 | paul.moore | set | messages: + msg278141 |
| 2016年10月05日 17:09:23 | zach.ware | link | issue28366 superseder |
| 2016年10月05日 17:05:16 | steven.daprano | set | nosy:
+ steven.daprano messages: + msg278138 |
| 2016年10月05日 15:47:40 | tim.golden | set | messages: + msg278135 |
| 2016年10月05日 15:45:20 | zach.ware | set | messages: + msg278134 |
| 2016年10月05日 15:35:57 | radialbeast | create | |