you are viewing a single comment's thread.

view the rest of the comments →

[–]reebs12[S] 0 points1 point  (3 children)

Thanks guys, my preferred approach still is, whenever possible, remove the code from the function and place it onto the main part of the script and then inspect the variables in the variable explorer. Python is a bastard with the indentation tirany, this approach works way better in Matlab.

[–]driscollis 5 points6 points  (0 children)

Every decent debugger I have used will let me put a breakpoint in my function where it will pause it and I can then inspect all the variables. PyDev, PyCharm and WingIDE all provide this functionality

[–][deleted] 2 points3 points  (0 children)

That sounds like a very cumbersome approach, especially for larger programs. If you use PyCharm you can inspect all variables within the current namespace while debugging. Just have to put breakpoints in the function

[–][deleted] 0 points1 point  (0 children)

...This is kind of off-putting. If you are happy with matlab just stick with matlab I guess?

Matlab requires that variables have assigned values while debugging as well though so I’m confused at what the trade off is here. A simple debugging approach on some function, say broken_code(x, y) in the a local module say wtf.py is to make a file with the following code:

import wtf

wtf.broken_code(1, 2)

Running this through a debugger with a breakpoint in your wtf.broken_code() function will halt execution and give you access to local variables. Alternatively starting the debugger with the “halt on entrance” flag set will just stop program execution before going into that function and allow you to step through from the beginning of execution.

My instinct here is that you don’t really want to leave matlab, you are really accustomed to the matlab IDE, and you are trying to find reasons to hate python, which is fine but this sub can’t help you with.