-
Notifications
You must be signed in to change notification settings - Fork 1
/
ipython_debug.py
50 lines (38 loc) · 1021 Bytes
/
ipython_debug.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""
Created October 12, 2012
Author: Spencer Lyon
iPython debugger tools.
"""
def set_trace():
"""
This function allows the user to set a quick pseudo-breakpoint
anywhere in a file. Just call set_trace() and the debugger will
break at that line.
Notes
-----
Taken from Wes McKinney's book Python for Data Analysis
"""
import sys
from IPython.core.debugger import Pdb
Pdb(color_scheme='Linux').set_trace(sys._getframe().f_back)
def debug(f, *args, **kwargs):
"""
Allows the user to launch pdb in any function.
Parameters
----------
f: function
The function you wish to debug
args:
The arguments that need to be passed to f
kwargs:
Named arguments that must be passed to f
Returns
-------
None
Notes
-----
Taken from Wes McKinney's book Python for Data Analysis
"""
from IPython.core.debugger import Pdb
pdb = Pdb(color_scheme='Linux')
return pdb.runcall(f, *args, **kwargs)