Skip to main content

A microlibrary for handling exceptions.

Example:

from try_default import try_default

foo = []
result = try_default(lambda: foo[0], {IndexError: 'n/a'})
# result: 'n/a'

foo = ['spam']
result = try_default(lambda: foo[0], {IndexError: 'n/a'})
# result: 'spam'

bar = {'egg': foo[0]}
result = try_default(lambda: bar['spam'], {IndexError: 'n/a'})
# Raises KeyError

Metadata

Release files for try-default 1.2

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

Source distribution (sdist)

Source distribution for try-default 1.2
File Size Uploaded
try_default-1.2.tar.gz 1.9 kB Details

Release files / try_default-1.2.tar.gz

Download URL try_default-1.2.tar.gz
Size 1.9 kB
Tags Source
SHA-256 checksum
How to use checksums
aab5c9bf00630df4a0842b6df7a75cfe7aba710f8699535a6c0aa731bbe1b669
BLAKE2b-256 checksum
How to use checksums
0d828c03c6223dc69d95915f3cdbfdca203d82c8f146c4a097b0fca4d88e9867
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.2 This release

1 release file

1.1

1 release file

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