Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging Python code in Notepad++

I use Notepad++ for writing and running Python scripts. It is a great text editor, except for debugging. Is there a way to step through the code, use break points, view variable values etc. in Notepad++ like you can in Visual Studio?

like image 884
Matej Avatar asked Sep 15 '11 11:09

Matej


2 Answers

Does such a plug-in exist? Not that I know of. I agree completely with qor72 on that note.

Is it possible to create such a plugin / functionality? Possibly.

After doing some quick digging, I did find a plugin that looks promising, Python Script. In short it allows you to run python scripts that can access the NPP modules (file menus etc...) as well as the Scintilla Methods which appear to give access to things like the markers on the pages.

To accomplish such a feat I could see the task being broken into a few large blocks (I feel a new open-source project coming on...)

  • Using Python Script, integrate the python debugger(PDB) as mentioned by Shashi.
  • Using the Scintilla Methods, add trace back calls where a NPP marker is placed
  • Redirect PDB outputs and process them to show where the file is stopped (again using the Scintilla methods).
  • While at the newly created breakpoint and using PDB determine all of the variables in the current namespace. Take this info and dump it to a CMD window, or if you want to get fancy some GUI created with Tk / wxPython

Closing Thoughts
While I think it's possible to create such a plug in, it would be quite an undertaking. Along that line, you might be better off trying to find a different editor that has this built into it already and just create macros (or whatever the IDE calls them) to add in the things you like most about NPP.

Please note that I am a daily user of NPP and have been for many years so I definitely understand why you'd like to have the functionally added to NPP. One of my favorite things about NPP is the speed in which it opens and searches files... moving to a bloated IDE, IMO, would not be worth it to me.

My current work flow is to do all of my editing in NPP and just double click to run the modules. If it fails or goes off in the weeds, I launch IDLE to debug it.

like image 78
Adam Lewis Avatar answered Sep 26 '22 13:09

Adam Lewis


I really hope someone tells me I'm wrong (I'd love to have that feature in Notepad++) but, Notepad++ is designed as a programmers editor, not an IDE. While it has a lot of cool functionality, that level of debugging isn't part of the core tool.

Not seeing anything in the npp-plugins either.

like image 39
AlG Avatar answered Sep 24 '22 13:09

AlG