Skip to main content

SOME DESCRIPTION

Project description

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, default="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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

try2-0.0.2.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

try2-0.0.2-py3-none-any.whl (2.2 kB view details)

Uploaded Python 3

File details

Details for the file try2-0.0.2.tar.gz.

File metadata

  • Download URL: try2-0.0.2.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for try2-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b129fefe68f27ec5a19f4db94bc86bf116fda55790188138aa3599373a821faf
MD5 ce793613cf0e3ee2d613636a3f0fbb1c
BLAKE2b-256 f9cf28188ed870be83bc2bda4098fdfc1ad52222af839456684059eff1aaa53f

See more details on using hashes here.

File details

Details for the file try2-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: try2-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for try2-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0e271137230a1df6013b935d5e8033e4c14d6215bb67cf9b96e0f9c0bff496f9
MD5 efecbb4f01e89d4c7bfe802d8fac9062
BLAKE2b-256 ab123318228c0ff81ceac8ee7f2c5e1ba044473e93706e5806e120b4f1401d23

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page