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

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 hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page