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.2.tar.gz
(5.8 kB
view hashes)
Built Distribution
Close
Hashes for exception_safe-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a1fb648ed7012648867b1ed0932f304806b4e591b0d3e5b5434cd1ec691c956 |
|
MD5 | 17d6b92d79892730add4e312c7dcd502 |
|
BLAKE2b-256 | 59eb72ce50c287be0569e3ef624332fdd769f196f939b11f5dab6a3409266a12 |