Skip to main content

tt's PyPI page Mac/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 as well as PyPy. tt is written in pure Python with no dependencies, so it only requires a compatible Python installation to run. 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')
>>> for inputs, result in t:
...     inputs, result
...
((False, False), False)
((False, True), True)
((True, False), 'x')
((True, True), 'x')
>>> t.equivalent_to(b)
True

License

tt uses the MIT License.

Download files

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

Source Distribution

ttable-0.5.1.tar.gz (586.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ttable-0.5.1-py2.py3-none-any.whl (25.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file ttable-0.5.1.tar.gz.

File metadata

  • Download URL: ttable-0.5.1.tar.gz
  • Upload date:
  • Size: 586.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ttable-0.5.1.tar.gz
Algorithm Hash digest
SHA256 2b01f3cb48e2c6eaa728187b1896b29f59f4d8e36596532fd5d029b0a36f81ec
MD5 f01e8fa9e214ecf1f6fb0447f000f833
BLAKE2b-256 26ef64776a44bc9a6391b3102a2d36bc185153fdad18cdd31d7b6ed3c40e6b5e

See more details on using hashes here.

File details

Details for the file ttable-0.5.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for ttable-0.5.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2839c3b6b97ee1d0f51b6984e2b3b760605df585029224c34bf0b8a245297d3b
MD5 1079995a320b1233114c71841a1b605b
BLAKE2b-256 b50e05f8db34769870b528e227da6d3eb4a2c1504c0827ff2868bc03ae20fd65

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page