[issue41434] IDLE: Option to warn user on "Run Module" if file is not Python source
Terry J. Reedy
report at bugs.python.org
Wed Jul 29 09:31:12 EDT 2020
Terry J. Reedy <tjreedy at udel.edu> added the comment:
I disagree. IDLE already shows a note -- in the editor window -- with the first noted divergence from python code marked. We are trying to keep IDLE relatively simple and not clutter it with trivial options.
ispythonsource is just a guess. The decision is whether turn on the colorizer and do python indents. For a new file, assume that it will be python code. Returning True for a directory is an error that is never hit as directories are not opened. Python files do not have to have a .py extensions, and files that have a .py extension do not have to be python files. But IDLE encourages use of the convention.
I would consider adding a note to the SyntaxError box when the error is on the first line. Something like "Is this really a Python code file?"
The only actual running of non-Python files I have seen reported, and I believe at least twice, is very beginner beginners running the saved Shell log, which begins "Python 3.x...", with the 3 highlighted. If this were recognized, the message might be "If this is a log of an interactive session, you cannot run it."
But I am not sure if this would really solve the problem of extreme ignorance. And anything added would have to have a test, and would be a possible maintenance burden.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41434>
_______________________________________
More information about the Python-bugs-list
mailing list