diff --git a/README.md b/README.md index fa5eb23..c87d782 100644 --- a/README.md +++ b/README.md @@ -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). -_1615 TILs and counting..._ +_1616 TILs and counting..._ See some of the other learning resources I work on: - [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 - [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) - [Dunder Methods](python/dunder-methods.md) - [Override The Boolean Context Of A Class](python/override-the-boolean-context-of-a-class.md) diff --git a/python/break-debugger-on-first-line-of-program.md b/python/break-debugger-on-first-line-of-program.md new file mode 100644 index 0000000..63d59b0 --- /dev/null +++ b/python/break-debugger-on-first-line-of-program.md @@ -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.