Process a series of conditional judgement with a chained call.
>>> from condition_chain import Condition
>>> condition = Condition(1).be(2).equal(2.0 - 2)\
.differ('a').instance_of(str).expect(lambda x: x, 1)
>>> print(condition.result(), condition.success, condition.failures, sep='\n')
False
[('be', 2), ('equal', 0.0), ('differ', 'a'), ('instance_of', 'str'), ('expect', ('<lambda>', 1))]
[('be', 2), ('equal', 0.0), ('instance_of', 'str')]
>>> condition = Condition([1,2,3]).contain(1).have('append').hold(3)
True
[('contain', 1), ('have', 'append'), ('hold', 3)]
[]
pip install condition_chain
Yixian Du (duyixian1234@outlook.com)