Have you ever had a hard time debugging π a Python π script?
If you say you haven't, you're lying! π
Let me show you something that you're gonna love me for!
Run your script with the `-i` flag!
By doing so, you get a REPL when the script finishes, EVEN with errors π£
1/4
Let me show you an example.
Below is a piece of code I wrote in a script called `foo`.
If you look closely, you'll see I'm generating 100 random integers...
All of them between 0 and... 0! So I'll generate 100 zeroes (my bug).
Later, a 0/0 division will throw an error.
2/4
When I run the code with the `-i` flag, the terminal shows the error and immediately opens a REPL!
From within the REPL I can inspect my variables and figure out what went wrong!
Isn't this amazing β
3/4
I hope you liked this mini-thread!
I love writing about Python π, problem solving π§ , and other cool things!
Be sure to follow me (@mathsppblog) so you don't miss a single drop of knowledge I share!
There's plenty more of where this came from π
See you around π
4/4
P.S. Would it be too much if I asked you to retweet the beginning of this thread?
Let's help everyone level up their Python π game!