Skip to main content

Errors as values for Python.

Project description

No exceptions

Errors as values for Python. A more functional alternative to try-except blocks, offering less indented code and a chainable API.

  • Do you hate exceptions?
  • Do you hate the extra indentation they bring?
  • Do you hate the convoluted flow of control they seed?
  • Do you hate APIs that throw exceptions in not-really-erroneous cases (like ZeroDivisionError, KeyError, IndexError, StopIteration)?

Use this package to switch from this:

def some_func() -> float:
    ...
    try:
        return numerator / denominator
    except ZeroDivisionError:
        return 0.0

to this:

from no_exceptions import try_expecting

def some_func() -> float:
    ...
    return try_expecting(lambda: numerator / denominator, ZeroDivisionError).unwrap_or(0.0)

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

no_exceptions-0.1.0.dev1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

no_exceptions-0.1.0.dev1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file no_exceptions-0.1.0.dev1.tar.gz.

File metadata

  • Download URL: no_exceptions-0.1.0.dev1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.19

File hashes

Hashes for no_exceptions-0.1.0.dev1.tar.gz
Algorithm Hash digest
SHA256 2e63bd422f710a918ac509b2fd39970c8e7ee19e6f51d94e24623df424f2863d
MD5 3647fc2ca18990e7ab7910d310c9c6f2
BLAKE2b-256 342a350a5ac4af00fda6cbaa440bbf218cbcc9d11d99f748353b9a94689d5006

See more details on using hashes here.

File details

Details for the file no_exceptions-0.1.0.dev1-py3-none-any.whl.

File metadata

File hashes

Hashes for no_exceptions-0.1.0.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 a707a64a0f181ac702903354f5ececd1f5336f2b4c0782e9544ffab07cccb882
MD5 2a5dab029f700b807e4088b9ef12a1b5
BLAKE2b-256 d871a77140ff7698dcfff82a649c4746787453aa1407050f1fbaa5f5e25add1b

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