> I can't figure out how to enable the .py shell and syntax highlighting
> for .wsgi file extensions using IDLE for windows ?
That's a Windows question, not a Python one. You have to associate the
.wsgi extension with the Python.File file type (the one used for .py
Thanks that does make it open exactly like a .py file, expect that
there is no syntax highlighting. Don't know if this is also a windows
issue or a IDLE issue ?
That's an IDLE issue; it only highlights files with .py (and possibly
Any chance they would make a highlight option in the menu ?
a) Ensure your scripts contain a shebang - no purpose on Windows, but IDLE
recognizes the file as a Python file. That is, make sure the very first
line is like this:
(it must start with #! and contain the word "python" somewhere)
b) Edit IDLE sources:
- Locate the file EditorWindow.py in the idlelib package.
- Add this line near the top:
- Modify function ispythonsource near line 580 as follows:
def ispythonsource(self, filename):
if not filename or os.path.isdir(filename):
base, ext = os.path.splitext(os.path.basename(filename))
if os.path.normcase(ext) in (".py", ".pyw"):
### add these 4 lines ###
with _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT, ext) as key:
ftype = _winreg.QueryValueEx(key, None)
if ftype.lower() in ("python.file","python.noconfile"):
### end ###
f = open(filename)
line = f.readline()
return line.startswith('#!') and line.find('python') >= 0
Thanks. Can you make a ispythonsource menu option in the next
python3.x release? There are many examples of txt, xml or wsgi files
having python parts in them.
>> >> >> > I can't figure out how to enable the .py shell and syntax ï¿œ
>> >> >> > highlighting
>> >> >> > for .wsgi file extensions using IDLE for windows ?
> Thanks. Can you make a ispythonsource menu option in the next
> python3.x release? There are many examples of txt, xml or wsgi files
> having python parts in them.
Please file a feature request at http://bugs.python.org/
I think a "This is a python file, apply syntax highlighting" menu option
is feasible, but doing the same only for part of a file is a lot harder.
does not matter its trival to see which part is python