Commit e4a17ba8 authored by Taddeus Kroes's avatar Taddeus Kroes

Added negation to Leaf representation.

parent 122476b1
......@@ -22,14 +22,14 @@ class Node(object):
return len(self.nodes)
def __eq__(self, node):
return isinstance(node, Node) \
and self.value == node.value and self.nodes == node.nodes
return isinstance(node, Node) and self.value == node.value \
and self.nodes == node.nodes
def __neg__(self):
copy = deepcopy(self)
copy.negated += 1
copied = deepcopy(self)
copied.negated += 1
return copy
return copied
def __str__(self):
return '<Node value=%s nodes=%s negated=%d>' \
......@@ -50,7 +50,7 @@ class Leaf(Node):
return len(str(self.value))
def __repr__(self):
return repr(self.value)
return repr('-' * self.negated + str(self.value))
def __str__(self):
return '-' * self.negated + str(self.value)
return '<Leaf %s>' % repr(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