Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
graph_drawing
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
graph_drawing
Commits
fbfd0f2a
Commit
fbfd0f2a
authored
Feb 19, 2012
by
Sander Mathijs van Veen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed __str__ with __repr__ and vice versa.
parent
db709d6c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
line.py
line.py
+3
-1
node.py
node.py
+7
-4
No files found.
line.py
View file @
fbfd0f2a
from
node
import
Leaf
from
traverse
import
traverse_depth_first
from
traverse
import
traverse_depth_first
...
@@ -183,6 +182,9 @@ def generate_line(root):
...
@@ -183,6 +182,9 @@ def generate_line(root):
>>> from node import Node, Leaf
>>> from node import Node, Leaf
>>> l0, l1 = Leaf(1), Leaf(2)
>>> l0, l1 = Leaf(1), Leaf(2)
>>> print generate_line(l0)
1
>>> plus = Node('+', l0, l1)
>>> plus = Node('+', l0, l1)
>>> print generate_line(plus)
>>> print generate_line(plus)
1 + 2
1 + 2
...
...
node.py
View file @
fbfd0f2a
...
@@ -35,6 +35,9 @@ class Node(object):
...
@@ -35,6 +35,9 @@ class Node(object):
return
'<Node value=%s nodes=%s negated=%d>'
\
return
'<Node value=%s nodes=%s negated=%d>'
\
%
(
str
(
self
.
value
),
str
(
self
.
nodes
),
self
.
negated
)
%
(
str
(
self
.
value
),
str
(
self
.
nodes
),
self
.
negated
)
def
__repr__
(
self
):
return
self
.
__str__
()
def
title
(
self
):
def
title
(
self
):
return
str
(
self
.
value
)
return
str
(
self
.
value
)
...
@@ -49,8 +52,8 @@ class Leaf(Node):
...
@@ -49,8 +52,8 @@ class Leaf(Node):
def
__len__
(
self
):
def
__len__
(
self
):
return
len
(
str
(
self
.
value
))
return
len
(
str
(
self
.
value
))
def
__repr__
(
self
):
return
repr
(
'-'
*
self
.
negated
+
str
(
self
.
value
))
def
__str__
(
self
):
def
__str__
(
self
):
return
'<Leaf %s>'
%
repr
(
self
)
return
'-'
*
self
.
negated
+
str
(
self
.
value
)
def
__repr__
(
self
):
return
'<Leaf %s>'
%
repr
(
str
(
self
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment