Skip to main content

Afterthought

PyPI version

A debugpy alternative to pdb.post_mortem() that allows you to attach any debugger to your code after an exception has been raised.

By default it is setup and tested with vscode, but feel free to contribute to add support for other debuggers.

Installation

pip install afterthought

Usage

import afterthought


def bombs():
    a = []
    print(a[0])


if __name__ == "__main__":
    try:
        bombs()
    except Exception as e:
        afterthought.debug(e)

You can then connect using any tool that supports https://github.com/microsoft/debugpy

Function Decorators

You can also use the @afterthought.debug_on_exception decorator to automatically attach the debugger to any function that raises an exception.

import afterthought


@afterthought.debug_on_exception(IndexError)
def bombs():
    a = []
    print(a[0])


if __name__ == "__main__":
    bombs()

VSCode Configuration

Add the following configuration to your .vscode/launch.json file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: Remote Attach",
            "type": "debugpy",
            "request": "attach",
            "connect": {
                "host": "localhost",
                "port": 5678
            },
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "."
                }
            ]
        }
    ]
}

Metadata

Release files for afterthought 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for afterthought 0.5.0
File Size Uploaded Provenance Actions
afterthought-0.5.0.tar.gz 2.4 kB Without provenance Details for afterthought-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for afterthought 0.5.0
File Interpreter ABI Platform Actions
afterthought-0.5.0-py3-none-any.whl Python 3 none any Details for afterthought-0.5.0-py3-none-any.whl

Total release size: 5.3 kB

Release files / afterthought-0.5.0.tar.gz

Download URL afterthought-0.5.0.tar.gz
Size 2.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ec1026b552a767cecad742262186073d826ca03912579fbc20dcdd6a830c369e
BLAKE2b-256 checksum
How to use checksums
5af790f07ee77643c60870505546f7673f2d2cc1905cda6c09cc5c8874ceea0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.1 CPython/3.8.10 Linux/5.4.0-169-generic

Release files / afterthought-0.5.0-py3-none-any.whl

Download URL afterthought-0.5.0-py3-none-any.whl
Size 2.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4324e8bbfb67b55af45ad97431eade67cefa3e6ebbee210a364685a7c98e8d7a
BLAKE2b-256 checksum
How to use checksums
66ce3cd76b494bbe5b85d0c00ef4821870acd988d842e7efeace5e5510d21409
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.1 CPython/3.8.10 Linux/5.4.0-169-generic

Security for afterthought 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page