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
Release history Release notifications | RSS feed
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 hashes)