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.

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

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

So..

```python
$ 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

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

or

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

Why??

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.

Source Distribution

raise_if-0.1.0.tar.gz (1.6 kB view details)

Uploaded Source

File details

Details for the file raise_if-0.1.0.tar.gz.

File metadata

  • Download URL: raise_if-0.1.0.tar.gz
  • Upload date:
  • Size: 1.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for raise_if-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3aeb5779dcdb3047115113f019cb9ae39a3695291070ad297887425f7cc8dc9b
MD5 fbc805fa4a7c01ac97d53613a1226f13
BLAKE2b-256 a2fd3f8cd2dd04035efa07ae643a83c7e9798e9ccdb625d24855d305b78ab220

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