Explore Courses Blog Tutorials Interview Questions
0 votes
in Machine Learning by (19k points)

The title says it all. When you are working R and using RStudio, its really easy and simple to debug something by dropping a browser() call anywhere in your code and seeing what goes wrong. Is there a way to do that with Python? I'm slowly getting very sick of print statement debugging.

1 Answer

0 votes
by (33.1k points)

There is a similar library in Python named ‘IPDB’. It is similar to R’s browser() function.

To import IDPB in python:

import ipdb


Use the above-mentioned code to explore more about ipdb. 

For example:

from ipdb import launch_ipdb_on_exception

def silly():

    my_list = [1,2,3]

    for i in xrange(4):

        print my_list[i]

if __name__ == "__main__":

    with launch_ipdb_on_exception():


Hope this answer helps.

Browse Categories