A microlibrary for handling exceptions
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
try_default-1.2.tar.gz
(1.9 kB
view details)
File details
Details for the file try_default-1.2.tar.gz
.
File metadata
- Download URL: try_default-1.2.tar.gz
- Upload date:
- Size: 1.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aab5c9bf00630df4a0842b6df7a75cfe7aba710f8699535a6c0aa731bbe1b669 |
|
MD5 | 5a28bb547c935af14703e21973615b10 |
|
BLAKE2b-256 | 0d828c03c6223dc69d95915f3cdbfdca203d82c8f146c4a097b0fca4d88e9867 |