Changed __str__ with __repr__ and vice versa.

parent db709d6c
from node import Leaf
from traverse import traverse_depth_first
......@@ -183,6 +182,9 @@ def generate_line(root):
>>> from node import Node, Leaf
>>> l0, l1 = Leaf(1), Leaf(2)
>>> print generate_line(l0)
1
>>> plus = Node('+', l0, l1)
>>> print generate_line(plus)
1 + 2
......
......@@ -35,6 +35,9 @@ class Node(object):
return '<Node value=%s nodes=%s negated=%d>' \
% (str(self.value), str(self.nodes), self.negated)
def __repr__(self):
return self.__str__()
def title(self):
return str(self.value)
......@@ -49,8 +52,8 @@ class Leaf(Node):
def __len__(self):
return len(str(self.value))
def __repr__(self):
return repr('-' * self.negated + str(self.value))
def __str__(self):
return '<Leaf %s>' % repr(self)
return '-' * self.negated + str(self.value)
def __repr__(self):
return '<Leaf %s>' % repr(str(self))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment