Grant Jenks Logo

Python Tribool Data Type

At the start of the year, I set a goal to develop and publish a Python package. I wanted to create something the community would find useful, that was useful to me, and that was small to “practice” publishing. Little did I realize how much I was over-thinking it. If you’re reading this now and considering a similar goal for yourself, then I encourage you to dive-in and leave your perfectionism behind. It’s really quite fun.

I’m happy to announce that I created and published my first Python package: the Tribool data type. Tribool objects implement three-valued boolean logic where the values are True, False, and Indeterminate. An Indeterminate value is either True or False. Computing with Indeterminate values sometimes has interesting results. For example, False and Indeterminate is always False but True and Indeterminate is Indeterminate. My implementation internally relies on a set of tables and maps Indeterminate to Python’s None datatype.

This is the first piece of software I’ve created that is truly public. You can test out the module yourself with “ pip install tribool ” from PyPI if you have Python installed. And you can inspect the source or even make contributions on Github. You can also read the Tribool documentation online.

I know I’m late to the party of sharing code in the Open Source World and it’s really kind of exciting. Better late than never. It’s so easy today to share tools and technologies. Thanks to all who have shared already. In particular, thanks to Kenneth Reitz for his samplemod project.