Use ipdb ("pip install ipdb" on the command line to install it).
Suppose you want to run the script "foo.py" from lines 18 through 23 . You want to start like this:
ipdb foo.py
Now let's j move to line 18 (i.e. ignore all lines until the 18th):
ipdb> j 18
Then we set reakpoint b on line 23 (we don't want to go any further):
ipdb> b 23
Finally, let it run:
ipdb> c
The task is completed :)
source share