Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ababino/reverse_tb
reverse_tb is a jupyter notebook magic that reverses the order of the traceback, making it easier to see the most relevant information at the top of the cell output.
https://github.com/ababino/reverse_tb
jupyter jupyter-magic jupyter-notebook magic traceback
Last synced: about 1 month ago
JSON representation
reverse_tb is a jupyter notebook magic that reverses the order of the traceback, making it easier to see the most relevant information at the top of the cell output.
- Host: GitHub
- URL: https://github.com/ababino/reverse_tb
- Owner: ababino
- License: apache-2.0
- Created: 2023-03-26T15:01:40.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-03-31T00:11:15.000Z (over 1 year ago)
- Last Synced: 2024-04-25T01:08:19.731Z (7 months ago)
- Topics: jupyter, jupyter-magic, jupyter-notebook, magic, traceback
- Language: Jupyter Notebook
- Homepage: https://ababino.github.io/reverse_tb/
- Size: 306 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
reverse_tb
================> reverse_tb is a jupyter notebook magic that reverses the order of the
> traceback, making it easier to see the most relevant information at
> the top of the cell output.## Install
``` sh
pip install reverse_tb
```## How to use
``` python
from reverse_tb.core import reverse_tb
`````` python
def foo():
return bar()def bar():
return baz()def baz():
try:
qux()
except KeyError as e:
raise Exception
return qux()def qux():
d = {}
return d['key']
`````` python
foo()
`````` python
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[2], line 9, in baz()
8 try:
----> 9 qux()
10 except KeyError as e:Cell In[2], line 16, in qux()
15 d = {}
---> 16 return d['key']KeyError: 'key'
During handling of the above exception, another exception occurred:
Exception Traceback (most recent call last)
Cell In[3], line 1
----> 1 foo()Cell In[2], line 2, in foo()
1 def foo():
----> 2 return bar()Cell In[2], line 5, in bar()
4 def bar():
----> 5 return baz()Cell In[2], line 11, in baz()
9 qux()
10 except KeyError as e:
---> 11 raise Exception
12 return qux()Exception:
`````` python
%%reverse_tb
foo()
`````` python
---------------------------------------------------------------------------
KeyError Traceback (last call first)
KeyError: 'key'
Cell In[2], line 16, in qux()
15 d = {}
---> 16 return d['key']
d = {}Cell In[2], line 9, in baz()
8 try:
----> 9 qux()
10 except KeyError as e:During handling of the above exception, another exception occurred:
Exception Traceback (last call first)
Exception:
Cell In[2], line 11, in baz()
9 qux()
10 except KeyError as e:
---> 11 raise Exception
12 return qux()Cell In[2], line 5, in bar()
4 def bar():
----> 5 return baz()Cell In[2], line 2, in foo()
1 def foo():
----> 2 return bar()Cell In[4], line 1
----> 1 foo()
`````` python
from reverse_tb.on import *
foo()
`````` python
---------------------------------------------------------------------------
KeyError Traceback (last call first)
KeyError: 'key'
Cell In[2], line 16, in qux()
15 d = {}
---> 16 return d['key']
d = {}Cell In[2], line 9, in baz()
8 try:
----> 9 qux()
10 except KeyError as e:During handling of the above exception, another exception occurred:
Exception Traceback (last call first)
Exception:
Cell In[2], line 11, in baz()
9 qux()
10 except KeyError as e:
---> 11 raise Exception
12 return qux()Cell In[2], line 5, in bar()
4 def bar():
----> 5 return baz()Cell In[2], line 2, in foo()
1 def foo():
----> 2 return bar()Cell In[4], line 1
----> 1 foo()
`````` python
reverse_tb_off()
foo()
`````` python
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[2], line 9, in baz()
8 try:
----> 9 qux()
10 except KeyError as e:Cell In[2], line 16, in qux()
15 d = {}
---> 16 return d['key']KeyError: 'key'
During handling of the above exception, another exception occurred:
Exception Traceback (most recent call last)
Cell In[3], line 1
----> 1 foo()Cell In[2], line 2, in foo()
1 def foo():
----> 2 return bar()Cell In[2], line 5, in bar()
4 def bar():
----> 5 return baz()Cell In[2], line 11, in baz()
9 qux()
10 except KeyError as e:
---> 11 raise Exception
12 return qux()Exception:
```