Skip to main content

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


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.1.tar.gz (1.9 kB view details)

Uploaded Source

File details

Details for the file try_default-1.1.tar.gz.

File metadata

  • Download URL: try_default-1.1.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for try_default-1.1.tar.gz
Algorithm Hash digest
SHA256 0971b3effd3152ef583e58cbb353374b670d9339b7339bc45d0d54062897a513
MD5 afe30abff0eae6c2d53cfb43ed7ccdeb
BLAKE2b-256 7a2cebd723130b04286be69ed147944116879b73a082cc659f8ccb6a9fe73657

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page