Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 962
Dmitry Kabanov Avatar asked Nov 20 '25 22:11

Dmitry Kabanov


1 Answers

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

like image 81
IxDay Avatar answered Nov 22 '25 11:11

IxDay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!