1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00

Add Break Debugger On First Line Of Program as a Python TIL

This commit is contained in:
jbranchaud
2025-03-12 10:35:08 -05:00
parent 6cbf1cb974
commit b1b2aa8982
2 changed files with 37 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
_1615 TILs and counting..._ _1616 TILs and counting..._
See some of the other learning resources I work on: See some of the other learning resources I work on:
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators) - [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators)
@@ -959,6 +959,7 @@ If you've learned something here, support my efforts writing daily TILs by
### Python ### Python
- [Access Instance Variables](python/access-instance-variables.md) - [Access Instance Variables](python/access-instance-variables.md)
- [Break Debugger On First Line Of Program](python/break-debugger-on-first-line-of-program.md)
- [Create A Dummy DataFrame In Pandas](python/create-a-dummy-dataframe-in-pandas.md) - [Create A Dummy DataFrame In Pandas](python/create-a-dummy-dataframe-in-pandas.md)
- [Dunder Methods](python/dunder-methods.md) - [Dunder Methods](python/dunder-methods.md)
- [Override The Boolean Context Of A Class](python/override-the-boolean-context-of-a-class.md) - [Override The Boolean Context Of A Class](python/override-the-boolean-context-of-a-class.md)

View File

@@ -0,0 +1,35 @@
# Break Debugger On First Line Of Program
One of the things I appreciate about how
[Delve](https://github.com/go-delve/delve) (the debugger for Go) works by
default is that when you start it up, it immediately breaks on the first line
of the program. This is as good a starting point as any regardless of whether
you have other breakpoints set.
As I was reading through the VS Code Python Debugger configuration docs, I
noticed [an option called
`stopOnEntry`](https://code.visualstudio.com/docs/python/debugging#_stoponentry).
It is turned off by default, but if you turn it on, then you get the same
behavior as I described for Delve. Nice!
This can be configured in a `.vscode/launch.json` file:
```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"stopOnEntry": true
}
]
}
```
Now, when running this debugger configuration profile, you'll break the
debugger on the first line of the program. From there add more breakpoints,
start stepping through, etc.