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, "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.4.tar.gz (2.3 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.4-py3-none-any.whl (2.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: try2-0.0.4.tar.gz
  • Upload date:
  • Size: 2.3 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.4.tar.gz
Algorithm Hash digest
SHA256 68bb40667c111850f0b32c86387e1bf989a09c664dabcbea15a1b1bb346aa62b
MD5 2f6e4a5861143b5d4070eb28d956f98c
BLAKE2b-256 ddfc3fb532e75d00bcc43912f6881e95c5c1a3afe73eacbb64d126eb2bb453d8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: try2-0.0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 39df280b37fc1e246b464a76989de096fce605ebc629fc7b9ca1a7baac004b7c
MD5 149effb359afc80796d740cc7d3416a1
BLAKE2b-256 1873bc4fe70405d7fd0230591a695418f02ab31998272f1fadf103a432589e16

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