A simple wrapper around contextlib.suppress
Project description
Suppres
Decorator to ignore exceptions in functions. A simple wrapper around contextlib.suppress.
Install
pip install suppress
Usage
from suppress import suppress
@suppress(ZeroDivisionError)
def zero_division_error_function():
return 1 / 0
def main():
print('First print')
zero_division_error_function()
print('Second print')
if __name__ == '__main__':
main()
Output:
First print
Second print
Async Usage
import asyncio
from suppress import async_suppress
@async_suppress(ZeroDivisionError)
async def zero_division_error_function():
return 1 / 0
async def main():
print('First print')
await zero_division_error_function()
print('Second print')
if __name__ == '__main__':
asyncio.run(main())
Output:
First print
Second print
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
suppress-0.1.1.tar.gz
(2.5 kB
view hashes)
Built Distribution
Close
Hashes for suppress-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1423cfdfadbc87a24e8e768a055a023df33a851b212545e506554996b1928d1c |
|
MD5 | cc99e33d703f1b4df66ec6c9c1c4fd3f |
|
BLAKE2b-256 | c3353e1b1f4bf3b1d7f113599f59da58a9dd44fe0157214e00a46b7332dc14ad |