Skip to main content

PyFuzzyBool

Additional boolean values: KindaTrue, KindaFalse, VeryTrue, and VeryFalse. (This is a joke project.)

Installation

To install with pip, run:

pip install pyfuzzybool

Quickstart Guide

In the Python language, the bool data type is a subclass of integers. The values True and False are literally the same as the integer values 1 and 0: you can use them any way you use integers: True + True + False + True evaluates to 3 and 'Hello[True]' evaluates to 'e'.

There is also a concept of "truthy" and "falsey" values in Python: 0, 0.0, blank strings, empty lists/dictionaries/tuples, and others are "falsey" values; when passed to bool() they will evaluate to the bool value False. All other values are "truthy" and when passed to bool() will evaluate to True.

Similarly, fuzzybool(1) and fuzzybool(0) will evaluate to True and False, but passing a float or int larger than 1.0 evaluates to VeryTrue, while passing a value less than 0.0 evaluates to VeryFalse. Passing a value between 0.0 and 1.0 will evaluate to KindaTrue half the time and KindaFalse the other time.

Here's some examples in the interactive shell:

>>> from pyfuzzybool import *
>>> KindaTrue == KindaFalse
True
>>> KindaTrue == True
False
>>> VeryTrue == True
True
>>> VeryFalse == False
True
>>> KindaFalse == False
False
>>> fuzzybool(1)
fuzzybool(True)
>>> fuzzybool(0.9)
KindaTrue
>>> fuzzybool(0)
fuzzybool(False)
>>> fuzzybool(-1)
VeryFalse
>>> fuzzybool(1.1)
VeryTrue
>>> fuzzybool()
KindaFalse
>>> KindaFalse < True
True
>>> KindaFalse > False
True
>>> KindaFalse <= KindaTrue
True

I think a lot of these can be changed. Should KindaTrue == True evaluate to True? Or should it evaluate to KindaTrue? Or evaluate half the time to KindaTrue and the other half KindaFalse?

This project is a joke, but this opens up a lot of issues to think about (if you have nothing better to do). After all, mathematics is just a bunch of made up, arbitrary rules about how to operate on abstract symbols. Math just happens to turn out to be unreasonably effective in science.

Contribute

If you'd like to contribute to PyFuzzyBool, check out https://github.com/asweigart/pyfuzzybool

Release files for PyFuzzyBool 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyFuzzyBool 0.1.2
File Size Uploaded
PyFuzzyBool-0.1.2.tar.gz 4.0 kB Details

Release files / PyFuzzyBool-0.1.2.tar.gz

Download URL PyFuzzyBool-0.1.2.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fbe83f54b49e1a7f3d0e18f662e969b8dc3b7fceb779e7832c1797689035ecfa
BLAKE2b-256 checksum
How to use checksums
f2f1393df2d6012042ee15970ddd9aadabc19713cd302e695b3dbf7c25e00e9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.9.0

Release history Release notifications | RSS feed

This release

0.1.2 This release

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page