You can run your program into pdb from the command line by running
python -m pdb your_script.py
It will break on the 1st line, then you'll be able to add a breakpoint wherever you want in your code using the break command, its syntax is:
b(reak) [[filename:]lineno | function[, condition]]
It is flexible enough to give you the ability to add a breakpoint anywhere.
Answer from mdeous on Stack OverflowYou can run your program into pdb from the command line by running
python -m pdb your_script.py
It will break on the 1st line, then you'll be able to add a breakpoint wherever you want in your code using the break command, its syntax is:
b(reak) [[filename:]lineno | function[, condition]]
It is flexible enough to give you the ability to add a breakpoint anywhere.
You can use:
from pdb import set_trace as bp
code
code
bp()
code
code
pdb trace don't stop where I put the breakpoint
(python dev) Guys, what do you use to examine values/ debug when running scripts?
how do I debug a python script?
Best way to debug python docker with docker compose? (Aside from vscode)
Videos
Hi,
This is the problem, I have this:
@.mark.django_db def test_it(): .... # some code a= '' import pdb; pdb.set_trace() b='' .... # some code
But It stops in:
> /usr/local/lib/python3.7/site-packages/pytz/__init__.py(230)utcoffset()
-> def utcoffset(self, dt):
(Pdb) l
225 def fromutc(self, dt):
226 if dt.tzinfo is None:
227 return self.localize(dt)
228 return super(utc.__class__, self).fromutc(dt)
229
230 -> def utcoffset(self, dt):
231 return ZERO
232
233 def tzname(self, dt):
And I don't know why. Any idea?