Skip to main content

Probably the small python package, only includes raise_if function

Project description

# raise_if

Python could have raise conditions like Ruby.

def i_must_have_truth(value)
raise TypeError, 'You must give me truth' if value == false

But the only one line option that works hurts PEP8
def i_must_have_truth(value):
if not value: raise TypeError('You must give me truth')


$ pip install raise_if

def i_must_have_truth(value):
raise_if(not value, TypeError, 'You must give me truth')

Pass exception type and arguments

raise_if(not 1 == 2, TypeError, 'Fails', another_arg='foo')


raise_if(not 1 == 2, TypeError('Fails', another_arg='foo'))


Because I am lazy and I do not like extra breaks in a chain of if statements!


Project details

Download files

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

Files for raise_if, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size raise_if-0.1.0.tar.gz (1.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page