Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

A library and command-line tool for working with Boolean expressions

Project description

tt's PyPI page Linux build on Travis CI Windows build on AppVeyor

Synopsis

tt is a Python library and command-line tool for working with Boolean expressions. Please check out the project site for more information.

Installation

tt is tested on CPython 2.7, 3.3, 3.4, 3.5, and 3.6. You can get the latest release from PyPI with:

pip install ttable

Basic Usage

tt aims to provide a Pythonic interface for working with Boolean expressions. Here are some simple examples from the REPL:

>>> from tt import BooleanExpression, TruthTable
>>> b = BooleanExpression('A xor (B and 1)')
>>> b.tokens
['A', 'xor', '(', 'B', 'and', '1', ')']
>>> b.symbols
['A', 'B']
>>> print(b.tree)
xor
`----A
`----and
     `----B
     `----1
>>> b.evaluate(A=True, B=False)
True
>>> t = TruthTable(b)
>>> print(t)
+---+---+---+
| A | B |   |
+---+---+---+
| 0 | 0 | 0 |
+---+---+---+
| 0 | 1 | 1 |
+---+---+---+
| 1 | 0 | 1 |
+---+---+---+
| 1 | 1 | 0 |
+---+---+---+
>>> t = TruthTable(from_values='01xx')
>>> t.ordering
['A', 'B']
>>> for inputs, result in t:
...     inputs, result
...
(<BooleanValues [A=0, B=0]>, False)
(<BooleanValues [A=0, B=1]>, True)
(<BooleanValues [A=1, B=0]>, 'x')
(<BooleanValues [A=1, B=1]>, 'x')
>>> t.equivalent_to(b)
True

License

tt uses the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ttable, version 0.6.0
Filename, size File type Python version Upload date Hashes
Filename, size ttable-0.6.0-cp27-cp27m-macosx_10_11_x86_64.whl (81.9 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size ttable-0.6.0-cp27-cp27m-win_amd64.whl (68.7 kB) File type Wheel Python version 2.7 Upload date Hashes View
Filename, size ttable-0.6.0-cp33-cp33m-win_amd64.whl (68.3 kB) File type Wheel Python version 3.3 Upload date Hashes View
Filename, size ttable-0.6.0-cp34-cp34m-win_amd64.whl (68.3 kB) File type Wheel Python version 3.4 Upload date Hashes View
Filename, size ttable-0.6.0-cp35-cp35m-win_amd64.whl (63.2 kB) File type Wheel Python version 3.5 Upload date Hashes View
Filename, size ttable-0.6.0-cp36-cp36m-win_amd64.whl (63.2 kB) File type Wheel Python version 3.6 Upload date Hashes View
Filename, size ttable-0.6.0.tar.gz (48.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page