Embedding IPython for debugging
Project description
ei
Install
From GitHub:
pip install git+https://github.com.djosix/ei.git
From PyPI:
pip install ei
Usage
patch
and unpatch
:
def main():
a, b, c = 1, 2, 3
raise ValueError()
if __name__ == '__main__':
import ei
# replace sys.excepthook with ei.Hook(select=True),
# refer to ei.Hook() for more options
ei.patch(select=True)
# set select=True if you want to choose which stack frame to embed into
# when the exception is raised, it will ask you if you want
# to embed an IPython shell with local variables of main()
main()
# restore sys.excepthook
ei.unpatch()
You can also use capture
with the with
statement:
def main():
a, b, c = 1, 2, 3
raise ValueError()
if __name__ == '__main__':
import ei
# context manager for patch() and unpatch()
with ei.capture(select=True):
main()
In case you want to change mode and color of the traceback class:
import ei
ei.probe()
'''
IPython debug hook is available!
class ListTB
modes: None
colors: ['NoColor', 'Linux', 'LightBG', 'Neutral', '']
class VerboseTB
modes: None
colors: ['NoColor', 'Linux', 'LightBG', 'Neutral', '']
class FormattedTB
modes: ['Plain', 'Context', 'Verbose', 'Minimal']
colors: ['NoColor', 'Linux', 'LightBG', 'Neutral', '']
class AutoFormattedTB
modes: ['Plain', 'Context', 'Verbose', 'Minimal']
colors: ['NoColor', 'Linux', 'LightBG', 'Neutral', '']
class ColorTB
modes: ['Plain', 'Context', 'Verbose', 'Minimal']
colors: ['NoColor', 'Linux', 'LightBG', 'Neutral', '']
class SyntaxTB
modes: None
colors: ['NoColor', 'Linux', 'LightBG', 'Neutral', '']
'''
ei.patch(tb_class='VerboseTB', tb_mode='Verbose', tb_color='Linux')
def fuckup(n):
n = 123 / n
return n
print(fuckup(0))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
ei-0.0.1-py3-none-any.whl
(8.1 kB
view hashes)