Threads for evandrix

    1. 40

      Wanna quickly figure out how you got to a particular point in a foreign codebase? Throw an exception there.

      1. 15

        I use import ipdb; ipdb.set_trace() in python almost pathologically. It’s 1 step up from an exception cause it drops you to a REPL, which is super convenient.

        1. 11

          With 3.7 we now have breakpoint() as a built-in.

          1. 2

            I’ve found the interactivity of the IPython debugger to be slightly better than the built-in one, but nearly all of my codebase is pinned to Python 3.5 for now.

            1. 6

              Use export PYTHONBREAKPOINT=ipdb.set_trace where ipdb is available and you don’t have to change your code for different environments. (at least once you’re on 3.7)

          2. 5

            I like to use IPython’s embed to achieve a similar goal.

            Add in a call to embed() as a breakpoint and find yourself in a full-blown IPython session with your objects in scope.

            1. 2

              also, ptpython

            2. 5

              I use binding.pry the same way in Ruby. Requires the pry gem, but it’s well worth it.

              1. 4

                I’ve been using pudb in the same manner. It’s got a TUI and it’s simple to jump into the REPL from there.

                1. 1

                  Ooh, pudb looks really cool! Might switch to using that

              2. 4

                Yeah, unless there’s a try catch higher in the callstack consuming everything.

                1. 3

                  Or unless you are in a minified React component with no source map.

                2. 2

                  Long time before I learned the debugger; statement in JavaScript. Still seems unusual.

                  1. 1

                    I use this all the time but always feel a little dirty and imposterish. I’m glad my method has been validated by a stranger on an internet board!

                    1. 1

                      For big monolithic web apps: if finding the backend code for an operation is less obvious than it should be, find some method that will almost always be called (in our app it’s a particular method that gets the user context for a request, but it could be various things) and breakpoint it.