Skip to main content

Boolean data type has two possible truth values to represent logic.
📦 PyPi, 📰 Pdoc, 📘 Wiki.

Here is my implementation of digital logic gates in software. That includes the basic gates not_, and_, or_, xor; their complements nand, nor, xnor; and 2 propositional logic (taught in discrete mathematics) gates imply, eq; and their complements nimply, neq. There is also a multiplexer, called select, and a True counter, called count. count can help you make custom gates, such as an alternate concept of xnor which returns True only if all inputs are the same (standard xnor returns True if even inputs are True). All of them can handle upto 8 inputs.

parse is influenced by "boolean" package, and is quite good at translating str to bool. It can also handle double negatives, eg. not inactive. You know the and_ of 2-inputs, but what of 1-input? What of 0? And what of the other gates? I answer them here.

Stability: Experimental.


from extra_boolean import *


parse("1")
parse("truthy")
parse("Not Off")
parse("Not Inactive")
# True

parse("cold")
parse("inactive")
parse("Negative Yes")
parse("Negative Aye")
# False

imply(True, False)
# False

eq(False, False)
# True

xor(True, True, True)
# True

select(1, True, False, True)
# False           ^

count(True, False, True)
# 2    ^            ^


Index

Function Action
parse Converts string to boolean.
not_ Checks if value is false.
and_ Checks if all values are true.
or_ Checks if any value is true.
xor Checks if odd no. of values are true.
nand Checks if any value is false.
nor Checks if all values are false.
xnor Checks if even no. of values are true.
eq Checks if antecedent ⇔ consequent (a ⇔ b).
neq Checks if antecedent ⇎ consequent (a ⇎ b).
imply Checks if antecedent ⇒ consequent (a ⇒ b).
nimply Checks if antecedent ⇏ consequent (a ⇏ b).
select Checks if ith value is true.
count Counts no. of true values.


References



Metadata

Release files for extra-boolean 1.0.6

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

Source distribution (sdist)

Source distribution for extra-boolean 1.0.6
File Size Uploaded
extra-boolean-1.0.6.tar.gz 6.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for extra-boolean 1.0.6
File Interpreter ABI Platform
extra_boolean-1.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 18.6 kB

Release files / extra-boolean-1.0.6.tar.gz

Download URL extra-boolean-1.0.6.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b93d8b86f7dedde075d16df11cb7db0a6c2edd4b1f510cad3f7ea40f773691c3
BLAKE2b-256 checksum
How to use checksums
c97c15a8645a16be7efa5eb3e81ecb34c275605550d209472e648e7d42d0c312
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.6.7

Release files / extra_boolean-1.0.6-py3-none-any.whl

Download URL extra_boolean-1.0.6-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c0bb6520f8451bee7c277f3160f1051c5c40bcc542631e56a046f7634834275
BLAKE2b-256 checksum
How to use checksums
1f54ef25ac6b22ef9832a626ceaf86d878e89408db5df007e58f398b1866c02e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.6.7

Release history Release notifications | RSS feed

This release

1.0.6 This release

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.17

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

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