try2
Simple wrapper for try-except blocks
Installation
pip install try2
Installation
pip install try2
Quickstart
from try2 import try2
def reciprocal(n):
return 1 / n
ls = [1, 2, 0, 3, 0, 4]
for number in ls:
x = try2(reciprocal, number, "bad")
print(number, "=>", x)
# 1 => 1.0
# 2 => 0.5
# 0 => bad
# 3 => 0.3333333333333333
# 0 => bad
# 4 => 0.25
Why I wrote this
I needed a simply one-liner try-except function for many of my projects, and I found myself defining helper try-except functions everywhere, which got annoying quickly
But what if I need a more complex try-except wrapper?
If your wrapper gets any more complex than this, it's probably a good idea to write your own function
Metadata
Release files for try2 0.0.4
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 | Actions |
|---|---|---|---|---|
| try2-0.0.4.tar.gz | 2.3 kB | Without provenance | Details for try2-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| try2-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for try2-0.0.4-py3-none-any.whl |
Total release size: 4.5 kB
Release files / try2-0.0.4.tar.gz
| Download URL | try2-0.0.4.tar.gz |
|---|---|
| Size | 2.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
68bb40667c111850f0b32c86387e1bf989a09c664dabcbea15a1b1bb346aa62b
|
|
BLAKE2b-256 checksum How to use checksums |
ddfc3fb532e75d00bcc43912f6881e95c5c1a3afe73eacbb64d126eb2bb453d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|
Release files / try2-0.0.4-py3-none-any.whl
| Download URL | try2-0.0.4-py3-none-any.whl |
|---|---|
| Size | 2.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
39df280b37fc1e246b464a76989de096fce605ebc629fc7b9ca1a7baac004b7c
|
|
BLAKE2b-256 checksum How to use checksums |
1873bc4fe70405d7fd0230591a695418f02ab31998272f1fadf103a432589e16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|
Security for try2 0.0.4
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.