内置函数、类型、异常和其他对象。
项目描述
该包使用修改版的Shunting Yard算法评估逻辑标签表达式。此包是cucumbers标签表达式的Python移植版本。
它也被radish使用。
安装
$ pip install tag-expressions
这里有一个预告
>>> from tagexpressions import parse
>>>
>>> expression = '( a and b ) or ( c and d )'
>>> compiled_expression = parse(expression)
>>> print(compiled_expression)
( ( a and b ) or ( c and d ) )
>>>
>>> data = ['a', 'b', 'c', 'd']
>>> assert compiled_expression.evaluate(data) == True
>>>
>>> data = ['a', 'c']
>>> assert compiled_expression.evaluate(data) == False
>>>
>>>
>>> expression = 'not a or b and not c or not d or e and f'
>>> compiled_expression = parse(expression)
>>> print(compiled_expression)
( ( ( not ( a ) or ( b and not ( c ) ) ) or not ( d ) ) or ( e and f ) )
>>>
>>> data = ['b', 'e', 'f']
>>> assert compiled_expression.evaluate(data) == True
>>>
>>> data = ['a', 'c', 'd']
>>> assert compiled_expression.evaluate(data) == False
用法
可用运算符
or - 两个给定变量的“or”连接
and - 两个给定变量的“and”连接
not - 单个变量的否定
在中缀中给出的每个其他标记都视为变量。
运算符优先级
从高到低
()
or
and
not
项目详情
关闭
tag-expressions-2.0.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | ffa626ef68e58157697a5e15d96d9a08a36d2120d3f72e6acfbfa04e5954b8f8 |
|
MD5 | 894c2f4a267b59baf04589f99062c8bc |
|
BLAKE2b-256 | e4208395065c523ce9f6030d93c1c7f564e684b2c3d0098cb34ee49160ee9332 |
关闭
tag_expressions-2.0.0-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 87f04c141f14ee70ec2cfa8a16409acf5e1e0e5cfed859c68533803343eb1eb9 |
|
MD5 | 35737dea11eb365e4ca581a6cd9837af |
|
BLAKE2b-256 | d7008900a6569172a4c177f4449725c5e149fa9140c757f760bcedfb3ff24c36 |