TryTry
install
pip install trytry
Example
handle exception
from trytry import trytry
@trytry
def my_function():
raise FileNotFoundError('file not found')
@trytry
def my_function2():
print(1 / 0)
@trytry.exception(ZeroDivisionError)
def handle_zero_division_error(func, e):
print(func.__name__, str(e))
@trytry.exception(FileNotFoundError)
def handle_file_not_found_error(func, e):
print(func.__name__, str(e))
if __name__ == '__main__':
my_function()
my_function2()
handle all exception
from trytry import trytry
@trytry
def my_function():
raise FileNotFoundError('file not found')
@trytry
def my_function2():
print(1 / 0)
@trytry.exception(Exception)
def handle_all_error(func, e):
print(func.__name__, str(e))
if __name__ == '__main__':
my_function()
my_function2()
All of the above exceptions are caught and are global exceptions. You can also catch exceptions for specific functions.
from trytry import trytry
@trytry
def my_function():
print(1 / 0)
@my_function.exception(ZeroDivisionError)
def handle_zero_division_error(func, e):
print(func.__name__, str(e))
Metadata
Release files for trytry 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| trytry-0.1.2.tar.gz | 2.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| trytry-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.3 kB
Release files / trytry-0.1.2.tar.gz
| Download URL | trytry-0.1.2.tar.gz |
|---|---|
| Size | 2.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e28653d6bce593148f12631103c1fde9cad2cff0a6ce3288ee42fdb83562372
|
|
BLAKE2b-256 checksum How to use checksums |
65397725b31b7236818074c2ac76e1d613d797119c1717218069f6c68b2db5b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.10.8 Darwin/22.2.0
|
Release files / trytry-0.1.2-py3-none-any.whl
| Download URL | trytry-0.1.2-py3-none-any.whl |
|---|---|
| Size | 2.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
da0ab7b2c336efca3cff92b8792df38c5c1838609c7ecd84b4ac131c1030fe6e
|
|
BLAKE2b-256 checksum How to use checksums |
3e6d059ba5a539b4f2fe03c641478b1f6fafb09f705a63eb31096b596a6b68b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.10.8 Darwin/22.2.0
|
Security for trytry 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.