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)
| 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 |