Skip to main content

Convenience package offering

Project description

This package allows you to do the fantastic import:

>>> from nihilo import nihil

This is a nice object which behaves like None but does accept method calls. Why would you want this?

So, we have:

>>> a_dict = { 'who': 'Parmenides' }
>>> print a_dict.get('who')
>>> print a_dict.get('where')
But you might want to do:
>>> a_dict.get('who').startswith('g')
>>> a_dict.get('where').startswith('g')
Traceback (most recent call last):
AttributeError: 'NoneType' object has no attribute 'startswith'
With nihil, you can do:
>>> print a_dict.get('where', nihil).startswith('g')

Note that casting to bool returns false, so you can easily test..:

>>> if a_dict.get('where', nihil).startwith('g'):
...   print "got it!"

nihil is very flexible, it will also allow you to call almost any method and it will return itself:

>>>'quux', frop=True)

And remember, ex nihilo nihil fit.

Project details

Release history Release notifications | RSS feed

This version


Download files

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

Files for nihilo, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size nihilo-0.1.tar.gz (652 Bytes) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate 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