Getting NppExec to understand the path to the current file in Notepad ++ (for Python scripts)

Using windows for the first time in quite some time I picked up Notepad ++, and I use the nppexec plugin to run python scripts. However, I noticed that notepad ++ does not pick up the directory where my script is stored. For example, I put "script.py" in "My Documents", however os.getcwd () prints "Program Files \ Notepad ++"

Does anyone know how to change this behavior? Not quite used to it on a Mac.

+6
python notepad ++ nppexec
source share
2 answers

Notepad ++> nppexec> follow $ (current directory)

+14
source share

At the beginning of your script:

you can add something like this:
import os os.chdir(os.path.dirname(__file__)) 
+2
source share

All Articles