Dmitry Kabanov
Dmitry Kabanov

Reputation: 891

Execute commands automatically when ipdb starts

I usually debug a python script with the help of the ipdb debugger by putting the following line into the source code:

import ipdb; ipdb.set_trace()

Then when I run the script, ipdb starts. Very often I need to plot numpy arrays in an interactive graph using matplotlib plotting library. I use the following commands to make interactive plotting possible inside the ipdb:

import matplotlib.pyplot as plt
plt.ion()

My question is whether it is possible to run these two commands automatically when ipdb starts.

Upvotes: 3

Views: 1392

Answers (1)

IxDay
IxDay

Reputation: 3707

I am currently looking at how to fix this in ipdb (loading the user configuration and init scripts). But for now there is a solution which I discovered reading the pdb documentation.

If you place a .pdbrc file in your home or at the root of your project directory, the script will be executed in the pdb shell (which also works for ipdb).

Here is the issue I am currently working on: https://github.com/gotcha/ipdb/issues/61

Upvotes: 4

Related Questions