WuTheFWasThat / magic_extract

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

magic_extract

Based on https://andyljones.com/posts/post-mortem-plotting.html

Examples run in interactive python:

from magic_extract import extract

def main():
    x = 3
    extract()

main()  # raises a RunTimeError
print(x)  # prints 3
from magic_extract import debug

def main(x):
    y = x - 2
    return x / y

debug(main, 4)  # returns 2
debug(main, 3)  # returns 3
debug(main, 2)  # raises ZeroDivisionError and extracts
print(y)  # prints 0
from magic_extract import decorate

@decorate()
def main(x):
    y = x - 2
    return x / y

main(4)  # returns 2
main(3)  # returns 3
main(2)  # raises ZeroDivisionError and extracts
print(y)  # prints 0

About

License:MIT License


Languages

Language:Python 100.0%