(Aug-02-2019, 09:06 PM)Gribouillis Wrote: [ -> ]So does it mean that there is no safe way to launch an editor for a python file in windows without knowing the editor?
Can just force to open to eg in notepad that's in all Windows version.
import subprocess
subprocess.run(['notepad', 'hello.py'])
Snippsat Wrote:Can just force to open to eg in notepad that's in all Windows version.
I think I'm going to do that and add a configuration option to let the user choose another editor.
Quote:As snippsat wrote:
It will all depend on what file association .py is set to in Windows.
If i set file association in Windows for .py to Notepad++,then this code will open hello.py in Notepad++.
After associating Notepad++ to Python file,
import os
os.startfile(<absolute path of the python file>) #Absolute path: Only incase os.chdir is not being used
If I run this code, then it is opening in Notepad++
Same happens with
import webbrowser
webbrowser.open(<absolute path of python file>)