MCPcopy Create free account
hub / github.com/ActiveState/code / __str__

Method __str__

recipes/Python/577898_23_Tree/recipe-577898.py:230–242  ·  view source on GitHub ↗

String representation of a tree (parentheses form)

(self)

Source from the content-addressed store, hash-verified

228 stack.append(node.getLink(j))
229
230 def __str__(self):
231 """ String representation of a tree (parentheses form) """
232 out, stack = [], [self.root]
233 while stack:
234 node = stack.pop()
235 if node == ')':
236 out.append(')')
237 continue
238 out.append('%s(' % str(node))
239 stack.append(')')
240 for j in xrange(node.refcnt - 1, -1, -1):
241 stack.append(node.getLink(j))
242 return ''.join(out)
243
244 def __nextSucc(self, node):
245 self.lastSearchDepth += 1

Callers

nothing calls this directly

Calls 6

strFunction · 0.85
xrangeClass · 0.85
getLinkMethod · 0.80
popMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected