Refactor str2in_tokens use op.available_op from Operator_set

This commit is contained in:
Benjamin Bertrand
2016-02-27 17:40:46 +03:00
parent c81776e037
commit 7f5b9059b1
2 changed files with 140 additions and 45 deletions

View File

@@ -54,6 +54,23 @@ class Operator_set(object):
except KeyError:
raise KeyError("{theOp} (arity: {arity}) is not available".format(theOp = op, arity = arity))
def available_op(self):
""" Get the set of available operators strings
>>> op = Operator_set()
>>> op.available_op()
set()
>>> op.store_operator(Add())
>>> '+' in op.available_op()
True
>>> '*' in op.available_op()
False
>>> op.store_operator(Mul())
>>> '*' in op.available_op()
True
"""
return set([i[0] for i in self._operators])
def can_be_operator(cls, symbole):
r"""
Tell if the symbole can be an operator