2021-09-16 repl python

less than 1 minute read

Using repl to debug python.
https://jvns.ca/blog/2021/09/16/debugging-in-a-repl-is-fun/

what’s a REPL?

REPL stands for “read eval print loop”. A REPL is a program that:

    reads some input from you like print(f"2 + 2 = {2+2}") (read)
    evaluates the input (eval)
    print out the result (print)
    and then goes back to step 1 (loop)

A couple years ago I used pry in ruby/chef a bunch and then I guess I forgot about it. Now this works for python too and it is WAY better than my print statement hell that I usually write.
Needless to say all you need to do in python is drop this one line in where you want to break and wam bam.
import ipdb; ipdb.set_trace() and then you get access to a REPL and you can interogate all your variables and write functions and whatever you want.
So simple, so clean.
Let’s hope I don’t forget about it again.

Categories:

Updated: