title: Stuck with __repr__ function, not working as I understand it
body: <p>I have a code which creates a graph, with nodes, and which keeps track of edges. This code itself appears to be working fine, but I cannot get the <strong>repr</strong> override to work how I would expect it to, after reading a few of the <strong>str</strong> vs <strong>repo</strong> and <strong>repr</strong>() returned non-string threads, I can't seem to isolate the cause of my troubles.</p>
  
  <pre><code>!/usr/bin/python
  class Edge:
      def __init__(self, here, there, txt):
          self.description = txt     # why am i making this jump?
          self.here = here    # where do i start
          self.there = there   # where to i end
          self.here.out += [self]  # btw, tell here that they can go there
  
      def __repr__(self):
          return "E(" + self.here.name + " &gt; " + self.there.name + ")"
  
  
  class Node:
      end = "."
      start = "!"
  
      def __init__(self, g, nid, name, stop=False, start=False):
          self.nid = nid
          self.graph = g  # where do i live?
          self.name = name  # what is my name?
          self.description = ""  # tell me about myself
          self.stop = stop  # am i a stop node?
          self.start = start  # am i a start node?
          self.out = []  # where do i connect to
  
      def also(self, txt):
          """adds text to description"""
          sep = "\n" if self.description else ""
          self.description += sep + txt
  
      def __repr__(self):
          y = "N( :id " + self.nid + \
              "\n   :name " + self.name + \
              "\n   :about '" + self.description + "'" + \
              "\n   :out   " + ",".join(str(n) for n in self.out) + " )"
  
  
  class Graph:
      def __init__(self):
          self.nodes = []  # nodes, stored in creation order
          self.keys = {}  # nodes indexed by name
          self.m = None  # adjacency matrix
          self.mPrime = None  # transitive closure matrix
  
      def __repr__(self):
          return "\n".join(str(u) for u in self.nodes)
  
      def node(self, name):
          """returns a old node from cache or a new node"""
          if not name in self.keys:
              self.keys[name] = self.newNode(name)
          return self.keys[name]
  
      def newNode(self, name):
          """ create a new node"""
          nid = len(self.nodes)
          tmp = Node(self, nid, name)
          tmp.start = Node.start in name
          tmp.end = Node.end in name
          self.nodes += [tmp]
          return tmp
  </code></pre>
  
  <p>It is my understanding that <strong>repr</strong> returns a string whenever its function is called by a string handler. More specifically, it references and instance as a string, looks for <strong>str</strong>, <strong>str</strong> points to <strong>repr</strong> and that gets returned as a string to its calling method. So for my program I have a graph, which is created just fine, but when I print it, it gets stuck concatenating the list it joins, returning it as an int instead of a string?</p>
  
  <p>I have tried casting different parts as a string thinking maybe <strong>repr</strong> wasn't being called because it had to be explicitly cast a string to work properly and a few other things. The short of my story is my <strong>repr</strong> is not being handled by the "\n".join() properly and somehow getting an int value from <code>",".join(str(n) for n in self.out)</code>, telling me it cannot concatenate a str and an int.</p>
  
  <p>I'm really at a loss, I've read through many google answers and texts on the use of repr, as well as many answers on here and haven't figure out what exactly I'm overlooking here.</p>
  
  <p>Here is how the graph itself is built, it reads in stagetext, where the first line is the node name, the exits start with >, and everything in between is a description of the node's location.</p>
  
  <p>The graph is what I'm supposed to edit, and it is supposed to simply print with <code>print graph("mystageText.txt")</code>, though I have seen most uses of <strong>repr</strong> with <code>repr(graph("myStageText.txt")</code>. I am thusly quite confused on the matter as a clear concise example of <strong>repr</strong> with lists of instances doesn't seem to be available.</p>
  
  <p>Thanks in advance for the help, hopefully this is concise enough for StackOverflow.
  Sorry if I was a bit too wordy while I was trying to be thorough about my problem.</p>