Skip to main content

Better than booleans

Project description

Cooleans

Cooleans is a Python package that aims to enhance the bool type in Python by adding a new possible value: "perhaps". This is a value that is neither True nor False, but rather may be one of those values. With cooleans, you can more accurately represent situations where the truth value of a statement is uncertain or unknown.

Getting Started

Installation

You can install cooleans using pip:
pip install cooleans

Usage

Here's an example of how to use cooleans in Python:

from cooleans import DefinitelyTrue, DefinitelyFalse, Perhaps

my_bool = DefinitelyTrue
if my_bool:
    print("This is definitely true")

my_bool = Perhaps
if my_bool >= Perhaps:
    print("This might be true")

In this example, we create a DefinitelyTrue coolean value and use it in an if statement to print "This is definitely true". We then create a Perhaps coolean value and use it in an if statement to print "This might be true". Note that Perhaps will always have a truth value of False when treated as a bool.

Supported Operators

Cooleans support the same logical operators as normal bools in Python, including:

  • and
  • or
  • not
  • ==
  • !=
  • <
  • >
  • <=
  • >=

Using Values Directly

Cooleans can be used directly as values since they are implemented as a Python class, like so:

from cooleans import DefinitelyTrue, DefinitelyFalse, Perhaps

print(DefinitelyTrue and DefinitelyFalse)

This code snippet will output DefinitelyFalse.

Contributing

We don't welcome contributions to cooleans yet.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

cooleans-0.2.0.tar.gz (1.8 kB view details)

Uploaded Source

File details

Details for the file cooleans-0.2.0.tar.gz.

File metadata

  • Download URL: cooleans-0.2.0.tar.gz
  • Upload date:
  • Size: 1.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.28.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.9.2

File hashes

Hashes for cooleans-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a56eae25e0834c08d290b53ddc99440aac8ffa1bfc0332407d5b96b8ee1eb0b7
MD5 105de777212f403f5c74c69f7edbe6ed
BLAKE2b-256 abae1ec6dc6f8798a6ad3a44adb02ea8bd870bd60918eb73db6f7b72bf117caf

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