自动生成真值表
项目描述
truths 是一个简单的工具,允许您从Python变量名称和短语中快速生成真值表
安装
pip install truths 或 git clone 并 pip install -e 以测试代码
使用简单
首先创建一些基本变量
import truths
print truths.Truths(['a', 'b', 'x'])
+---+---+---+ | a | b | x | +---+---+---+ | 0 | 0 | 0 | | 0 | 0 | 1 | | 0 | 1 | 0 | | 0 | 1 | 1 | | 1 | 0 | 0 | | 1 | 0 | 1 | | 1 | 1 | 0 | | 1 | 1 | 1 | +---+---+---+
添加一些短语
现在让我们使用这些基本变量并传递一些短语!您的基变量可以是您想要的任何内容,但必须是有效的Python变量名称。短语也必须是有效的Python
from truths import Truths
print Truths(['a', 'b', 'cat', 'has_address'], ['(a and b)', 'a and b or cat', 'a and (b or cat) or has_address'])
+---+---+-----+-------------+-----------+----------------+---------------------------------+ | a | b | cat | has_address | (a and b) | a and b or cat | a and (b or cat) or has_address | +---+---+-----+-------------+-----------+----------------+---------------------------------+ | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | 0 | 0 | 0 | 1 | 0 | 0 | 1 | | 0 | 0 | 1 | 0 | 0 | 1 | 0 | | 0 | 0 | 1 | 1 | 0 | 1 | 1 | | 0 | 1 | 0 | 0 | 0 | 0 | 0 | | 0 | 1 | 0 | 1 | 0 | 0 | 1 | | 0 | 1 | 1 | 0 | 0 | 1 | 0 | | 0 | 1 | 1 | 1 | 0 | 1 | 1 | | 1 | 0 | 0 | 0 | 0 | 0 | 0 | | 1 | 0 | 0 | 1 | 0 | 0 | 1 | | 1 | 0 | 1 | 0 | 0 | 1 | 1 | | 1 | 0 | 1 | 1 | 0 | 1 | 1 | | 1 | 1 | 0 | 0 | 1 | 1 | 1 | | 1 | 1 | 0 | 1 | 1 | 1 | 1 | | 1 | 1 | 1 | 0 | 1 | 1 | 1 | | 1 | 1 | 1 | 1 | 1 | 1 | 1 | +---+---+-----+-------------+-----------+----------------+---------------------------------+
更喜欢布尔词吗?
很酷吧?如果您喜欢True/False而不是数字,请传递 ints=False
from truths import Truths
print Truths(['a', 'b', 'x', 'd'], ['(a and b)', 'a and b or x', 'a and (b or x) or d'], ints=False)
+-------+-------+-------+-------+-----------+--------------+---------------------+ | a | b | x | d | (a and b) | a and b or x | a and (b or x) or d | +-------+-------+-------+-------+-----------+--------------+---------------------+ | False | False | False | False | False | False | False | | False | False | False | True | False | False | True | | False | False | True | False | False | True | False | | False | False | True | True | False | True | True | | False | True | False | False | False | False | False | | False | True | False | True | False | False | True | | False | True | True | False | False | True | False | | False | True | True | True | False | True | True | | True | False | False | False | False | False | False | | True | False | False | True | False | False | True | | True | False | True | False | False | True | True | | True | False | True | True | False | True | True | | True | True | False | False | True | True | True | | True | True | False | True | True | True | True | | True | True | True | False | True | True | True | | True | True | True | True | True | True | True | +-------+-------+-------+-------+-----------+--------------+---------------------+
它是如何工作的
查看代码!幕后操作是将基值放在对象上下文中,并为它们生成一个值网格。然后,短语在对象上下文中针对该值网格中的每一行进行评估
项目详情
关闭
truths-1.2.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 99287a3da4f8982b90613f0aafae5fa94fc001560fa881ec3c8ea3963ed8362b |
|
MD5 | 24d07f68ad2b0718f42529ca596ffd93 |
|
BLAKE2b-256 | 3f5abbdd1bd5caebb13cbbe23a4a4b7458e449235c8e8ea7075a34a48676ace7 |