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.dev2.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.dev2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: no_exceptions-0.1.0.dev2.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.dev2.tar.gz
Algorithm Hash digest
SHA256 30fc38421e5ac5a28498bec231db4a9c6ddd79ec08c4871624ec1a540b837855
MD5 865b8f15732db0160ecde1ee58c99c8e
BLAKE2b-256 fe3d3a6a18c0cf8fbf250a2d5ee3903c1dd25fdc44e253425a6841f14b6fc523

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for no_exceptions-0.1.0.dev2-py3-none-any.whl
Algorithm Hash digest
SHA256 0969fa0fcf3b1f066a4c4ef84d34e2b46d40395599d2684894d29428ef55d139
MD5 3d1030307736cae8327d2c7a4882d6bf
BLAKE2b-256 74bd8499fb1cee17e602ddd0215afd650c3d862798dbf6792c3e6cc4c5e0aff2

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