Change from_str method name for muttable tree
This commit is contained in:
parent
876a1fc63c
commit
251ec6c83b
@ -62,14 +62,14 @@ class Tree(object):
|
||||
|
||||
:example:
|
||||
|
||||
>>> t = MutableTree.fromStr("2+3*4")
|
||||
>>> t = Tree.from_str("2+3*4")
|
||||
>>> print(t)
|
||||
+
|
||||
> 2
|
||||
> *
|
||||
| > 3
|
||||
| > 4
|
||||
>>> t = MutableTree.fromStr("(2+3)*4")
|
||||
>>> t = Tree.from_str("(2+3)*4")
|
||||
>>> print(t)
|
||||
*
|
||||
> +
|
||||
@ -364,7 +364,7 @@ class Tree(object):
|
||||
>>> nested_par = ("+", (
|
||||
... ("*", (3, 4)),
|
||||
... 2))
|
||||
>>> t = Tree.from_nested_parenthesis(nested_par)
|
||||
>>> t = Tree.from_str("3*4+2")
|
||||
>>> [l for l in t.get_leafs()]
|
||||
[3, 4, 2]
|
||||
>>> {type(l) for l in t.get_leafs()}
|
||||
@ -480,25 +480,25 @@ class MutableTree(Tree):
|
||||
self.right_value = right_value
|
||||
|
||||
@classmethod
|
||||
def fromStr(cls, expression):
|
||||
def from_str(cls, expression):
|
||||
""" Initiate the MutableTree
|
||||
|
||||
:example:
|
||||
>>> t = MutableTree.fromStr("2+3*4")
|
||||
>>> t = MutableTree.from_str("2+3*4")
|
||||
>>> print(t)
|
||||
+
|
||||
> 2
|
||||
> *
|
||||
| > 3
|
||||
| > 4
|
||||
>>> t = MutableTree.fromStr("(2+3)*4")
|
||||
>>> t = MutableTree.from_str("(2+3)*4")
|
||||
>>> print(t)
|
||||
*
|
||||
> +
|
||||
| > 2
|
||||
| > 3
|
||||
> 4
|
||||
>>> t = MutableTree.fromStr("4*(-2+3)")
|
||||
>>> t = MutableTree.from_str("4*(-2+3)")
|
||||
>>> print(t)
|
||||
*
|
||||
> 4
|
||||
|
Loading…
Reference in New Issue
Block a user