title: Making two classes reference eachother
body: <p>I'm trying to make a text adventure where different "place" classes can point to eachother. </p>
  
  <p>For instance, I have a <code>Manager</code> class that has a reference to each place. Then I have a <code>Home</code> class, and a <code>Club</code> class, with references to eachother through manager. The problem is that I can't instantiate them due to the circular reference. </p>
  
  <p>Here's how I solved it, but it's ugly, because I have to create the <code>places</code> member inside of a method instead of <code>__init__</code>. </p>
  
  <pre><code>class Manager:
    def __init__(self):
      self.home = Home(self)
      self.club = Club(self)
  
  class Home:
    def __init__(self, manager):
      self.places = {}
      self.manager = manager
  
    def display_plot_and_get_option (self):
      print "where do you want to go?"
      return 'club' #get this from user
  
    def get_next_place(self, place_name):
      self.places = { #THIS IS THE BAD PART, which should be in __init__ but can't
        'home':self.manaer.home
        'club':self.manaer.club }
      return self.places[place_name]
  
  class Club:
    #similar code to Home
    pass
  
  manager = Manager()    
  while (True):
    place_name = manager.current_place.display_plot_and_get_option()
    manager.current_place = manager.current_place.get_next_place(place_name)
  </code></pre>
  
  <p>In c++ I would set my dict up in the constructor, where it should be, and it would use the pointer of the <code>Manager</code>'s <code>home</code> or <code>club</code> members, since I only want 1 instance of each place. How can I do this in python?</p>
  
  <p><strong>edit</strong>: expanded code example</p>