title: Why can't I have a class which contains a list of objects of the same class?
body: <p>I have the following class:</p>
  
  <pre><code>class Group(object):
      _name = ''
      _link = ''
      _collection = []
  </code></pre>
  
  <p>And I have the following function:</p>
  
  <pre><code>def getSubGroups(url, groups):
      group = groups[0]
      #sleep(15)
      html = requests.get(url+group.getLink())
      content = BeautifulSoup(html.text, "lxml")
      subGroup = None
      #Retrieving groups and people listed above these groups
      for div in content.find_all('div', {"class":["size14", "person-box"]}):
        #Group
        if "size14" in div.attrs['class']:
          if subGroup != None:
            #Adding a subgroup to its repective subgroup
            group.addCollection(subGroup)
            print 'NFL = ', group.getName()
            print '2014...', subGroup.getName()
            print 'List of groups', group.getCollection()
            print 'List of persons', subGroup.getCollection()
            break
          subGroup = Group()
          subGroup.setLink(div.a['href'])
          subGroup.setName(div.text)
        #Person
        if "person-box" in div.attrs['class']:
          divPerson = div.find('div', 'name')
          person = Person()
          person.setName(divPerson.text)
          person.setLink(divPerson.a['href'])
          #Adding a person to its repective group
          subGroup.addCollection(person)
      return group
  </code></pre>
  
  <p>That print gives me the following output:</p>
  
  <pre><code>NFL =  NFL Players 
  2014... 2014 NFL Draft Picks and Rookies
  List of groups [&lt;Person.Person object at 0x7fd79a4bff50&gt;, &lt;Person.Person object at
  0x7fd79a4bff90&gt;, ..., &lt;Group.Group object at 0x7fd79a4bff10&gt;]
  List of persons [&lt;Person.Person object at 0x7fd79a4bff50&gt;, &lt;Person.Person object at
  0x7fd79a4bff90&gt;, ..., &lt;Person.Person object at 0x7fd79a454990&gt;,
  &lt;Group.Group object at 0x7fd79a4bff10&gt;]
  </code></pre>
  
  <p>As those who paid attention can see, I am running a test and I was expecting to have => List of groups <code>[&lt;Group.Group object at 0x7ff54bb86350&gt;]</code>, but instead it added all of the person objects there as well.</p>
  
  <p>Just to test my sanity, I created another class named Subgroup and now it works fine for me. But still, in Java or C++ I could do that, I suppose. Why can't I with python? I didn't want to have to create another class that is exactly the same!</p>