Live data from Hacker News

Drop into REPL when your Python script crashes

annadapb.substack.com

1–4 of 4 posts

Re: Drop into REPL when your Python script crashes

#2
> Too long; didn’t read: Add this at the beginning of your “main” script.

Better yet, put it in sitecustomize.py or usercustomize.py , which are intentionally provided as hooks to customize your environment. Now you get it for all your projects, and don't have to take it out for packaging (or leave it in, I guess there are people who would do that...).

https://docs.python.org/3/library/site.html

Re: Drop into REPL when your Python script crashes

#3
pytest has a --pdb flag:

  pip install pdbpp
  pytest --pdb
pdbpp: https://github.com/pdbpp/pdbpp

pytest docs > How to handle test failures > Using pdb — The Python Debugger with pytest > Dropping to pdb on failures: https://docs.pytest.org/en/stable/how-to/failures.html

Re: Drop into REPL when your Python script crashes

#4
post #2

> Too long; didn’t read: Add this at the beginning of your “main” script. Better yet, put it in sitecustomize.py or usercustomize.py , which are intentionally provided as hooks to customize your environment. Now you get it for all your projects, and don't have to take it out for packaging (or leave it in, I guess there are people who would do that...). https://docs.python.org/3/library/site.html

Thank you for the usercustomize.py tip.