Daily Shaarli

All links of one day in a single page.

July 26, 2016

Debugging Python script more easily with Notepad++

[path_to_script]\python-no-autoclose.py "$(FULL_CURRENT_PATH)"

In the menu Run > Run, put this in the text field and hit Save, give it a name and a key combination. Personally I used Shift+F5. Be wary than all key combinations might not work, try it to make sure or change it.

The script:

import sys
import traceback
import subprocess
import os
import pathlib

if sys.argv[1:]: # Failsafe
try:
os.chdir(str(pathlib.Path(sys.argv[1]).parent))
except Exception as e:
traceback.print_exc()

try:
    subprocess.call(['python', sys.argv[1]])
except Exception as e:
    traceback.print_exc()

else:
print('I\'m very confused...')

print()
input('Press Enter to exit.')