Skip to main content

Exception? Just keep mapping.

Project description

import mapexcept

# Basic usage
for i in mapexcept(['1', '2', '3', 'FOOBAR', '4'])[ValueError](int):
    print(i)

# 1
# 2
# 3
# 4

print('


')

# With default values
for i in mapexcept(['1', '2', '3', 'FOOBAR', '4'])[ValueError:0](int):
    print(i)

# 1
# 2
# 3
# 0
# 4

print('


')

# As a decorator
@mapexcept(['1', '2', '3', 'FOOBAR', '4'])[ValueError:0]
def conversion(val:str):
    return int(val)

for i in conversion:
    print(i)

# 1
# 2
# 3
# 0
# 4

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

mapexcept-1.0.0.tar.gz (1.8 kB view details)

Uploaded Source

File details

Details for the file mapexcept-1.0.0.tar.gz.

File metadata

  • Download URL: mapexcept-1.0.0.tar.gz
  • Upload date:
  • Size: 1.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.4

File hashes

Hashes for mapexcept-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b31ff97b3e27db9f89f6708f3b64170bf9800fab24f25a7734104e243942a46c
MD5 be3d0d344573272ed3d682e5aa8aed56
BLAKE2b-256 9110a2c4d42d8fac6d5672ca28b389125109358472dd06792f24e2a49944025f

See more details on using hashes here.

Supported by

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