0

I am new to debugging in Python, and I currently use Hydrogen within Atom to do most of my Python work. I have looked into debugging, and it seems that the Python package pdb is the standard way to debug in Python. Most of the examples I can find seem to require using a command line on a .py file. However, in Hydrogen I would want to run it within the kernel on individual lines of the code, since I don't think pdb will work on a markdown (.md) file. Is there a way I can debug within my workflow, or do I need to make .py files of my code and run pdb on them?

Lambert_W
  • 155
  • 1
  • 9

1 Answers1

0

I had read this answer and tried to implement "C. From Within Your Program". It had thrown errors, and I gave up. However, I went to the source that the answer had cited, and used this code:

import pdb

class MyObj(object):

    def __init__(self, num_loops):
        self.count = num_loops

    def go(self):
        for i in range(self.count):
            pdb.set_trace()
            print(i)
        return

if __name__ == '__main__':
    MyObj(5).go()

From this, I was able to get pdb to run in Hydrogen.

Lambert_W
  • 155
  • 1
  • 9