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