Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Stepping Through Code

Give Feedback

There are two commands you can use to step through code when debugging:

  1. n stands for next. It allows you to move to the next logically executed line of code, ignoring function calls. This is the equivalent of step over in most debuggers.

  2. s stands for step. If you’re stopped on a function call, move into that function and stop there. This is the equivalent of step into in most debuggers.

Pygator on Sept. 22, 2019

Is there any good c++ equivalent for all of these features? Thank you!! This will be very handy.

Geir Arne Hjelle RP Team on Sept. 22, 2019

pdb is very much based on gdb, the GNU debugger: www.gnu.org/software/gdb/

gdb supports languages like C, C++, Fortran, etc and uses essentially the same commands as pdb.

Pygator on Sept. 23, 2019

Thanks for the reference.

Sachin on Dec. 14, 2019

For example3.py, on 13th line it seems we are setting up the pdb trace, not sure then why your video execution pointer is on print(f”path = {get_path(filename)}”). When I run the same command, I see the execution pointer is on filename_path = get_path(filename).

Code “”” import os def get_path(filename): “”“return file’s path of empty string if no path”“” head, tail = os.path.split(filename)

return head

filename = file import pdb; pdb.set_trace() filename_path = get_path(filename)

print(f”path = {get_path(filename)}”) “”” output:

/Users/skamble/GitHub/WALMART/example2.py(11)<module>() -> filename_path = get_path(filename) (Pdb) l 6 return head 7 8 9 filename = file 10 import pdb; pdb.set_trace() 11 -> filename_path = get_path(filename) 12 13 print(f”path = {get_path(filename)}”) [EOF]

Become a Member to join the conversation.