Catch all exceptions and return None
Project description
Safe
This is quite a simple package. It catches all exceptions within a given callable and returns None, if they occur and the return-value of the callable if not.
def boom():
raise Exception()
return 1
def non_boom():
return 2
a = safe(lambda: boom())
b = safe(lambda: non_boom())
assert a == None
assert b == 2
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
exception_safe-0.0.3.tar.gz
(5.8 kB
view details)
Built Distribution
File details
Details for the file exception_safe-0.0.3.tar.gz
.
File metadata
- Download URL: exception_safe-0.0.3.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ef879cd1d34136244e150b7b897e7e37458da52e601c8b1b7e588e6a2d9b012 |
|
MD5 | 45ce191256aed3e4f95a5ada355aaea4 |
|
BLAKE2b-256 | d73eadf4613fc5a829fdcd1a552233e41940e8c431eba8c8df5c589a55f71adc |
File details
Details for the file exception_safe-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: exception_safe-0.0.3-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46648f78d24c3bc6b1d2963e74346506a5a045f3f27ed9284229a410ef124570 |
|
MD5 | 03c00334ebed0821990d27b6d602fb24 |
|
BLAKE2b-256 | d0db44193f797c1d509db5192e6972102b1ed6f3b4b30c0dd0f8a61a6d1b8437 |