Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Debugging scripts basics
#6
(Apr-24-2020, 02:27 AM)bako Wrote: Care for an example? From what I can tell it's to debug modules, not the script that I'm actually importing it into.

It will work fine for your regular script as well.

$ python -m pdb yourscript.py
The main commands you'll want to familiarize yourself with are l for listing at the current location, b to set a breakpoint on a line or a function, c to continue to a breakpoint, n for next line, s to step into a sub function, and you can p to print variables and data.

If you are running 3.7 or later, you can simply put the breakpoint() function in your code to stop at that location and examine variables. You don't have to explicitly import pdb.
Reply


Messages In This Thread
Debugging scripts basics - by bako - Apr-24-2020, 01:23 AM
RE: Debugging scripts basics - by Larz60+ - Apr-24-2020, 01:49 AM
RE: Debugging scripts basics - by bako - Apr-24-2020, 02:27 AM
RE: Debugging scripts basics - by bowlofred - Apr-24-2020, 05:00 AM
RE: Debugging scripts basics - by buran - Apr-24-2020, 02:58 AM
RE: Debugging scripts basics - by bako - Apr-24-2020, 03:00 AM
RE: Debugging scripts basics - by Larz60+ - Apr-24-2020, 05:59 AM
RE: Debugging scripts basics - by ndc85430 - Apr-24-2020, 06:03 AM
RE: Debugging scripts basics - by Larz60+ - Apr-24-2020, 06:18 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Learned Python Basics, what now? muzikman 20 6,257 Oct-11-2021, 01:34 AM
Last Post: Underscore
  PYserial basics? bako 10 5,194 Apr-26-2020, 09:15 PM
Last Post: bowlofred
  [split] Debugging scripts basics tultalk 5 3,145 Apr-25-2020, 01:02 AM
Last Post: menator01
  Problem with basics Wraith2102 2 2,028 Jun-17-2019, 06:51 PM
Last Post: perfringo
  Dictionary Basics pythonjm 5 3,572 Nov-26-2018, 11:11 PM
Last Post: pythonjm
  What to do after learning python basics xyzabc12310000 1 2,874 May-20-2018, 11:43 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020