title: Example of a chain of referents, referrers
body: <p>Working further with the <a href="https://pypi.python.org/pypi/dill" rel="nofollow noreferrer">Dill package</a>. Posted yesterday exemplifying some <a href="https://stackoverflow.com/questions/25651491/referrers-referents-parents-and-children">ignorance of referents, referrers, inheritance and containers</a>. The answer was insightful, but I'm still having trouble coming up with examples that show a few levels of depth in referrer and referent chains.</p>
  
  <p>Yesterday I was thinking that an <code>instance</code> would be a <code>referrer</code> to it's class. In the Dill docs <em>children</em> are the <em>referrers</em>, so in that case a <em>child</em> of <code>depth=2</code> would be a <em>grandchild</em>, right? And would that be an <code>object</code> that <em>refers</em> (points) to another <code>object</code> that refers to another <code>object</code>?</p>
  
  <p>What would be an example of an object that has a chain of <em>referents</em> and <em>referrers</em> of at least a depth of two?</p>
  
  <p>Consider:</p>
  
  <pre><code> import dill
  
  class GreatGrandparentClass(object):
      """A Great Grandparent class"""
  
      name = "Henrietta Ancient One"
  
  class GrandparentClass(GreatGrandparentClass):
      """A Grandparent class"""
  
  class ParentClass(GrandparentClass):
      """A Grandparent class"""
  
  great_grand_parent = ParentClass().name
  
  print ("Children (depth=2):")
  
  for element in dill.detect.children(
                          great_grand_parent, 
                          list, 
                          depth=2, 
                          ignore=(globals())):
      print(element)
  
  print ("Parents:")
  for element in dill.detect.parents(                        
                          great_grand_parent, 
                          list, 
                          depth=2, 
                          ignore=(globals())):
      print(element)
  </code></pre>
  
  <p>returns:</p>
  
  <pre><code>Children (depth=2):
  ['\npython pydill.py\n\n', 'dill', 'object', 'A Great Grandparent class', 'i', 'Henrietta Ancient One', 'GreatGrandparentClass', 'GreatGrandparentClass', 'A Grandparent class', 'GrandparentClass', 'GrandparentClass', 'A Grandparent class', 'ParentClass', 'great_grand_parent', 'ParentClass', 'i', 'Children (depth=2):', 'element', 'dill', 'detect', 'children', 'great_grand_parent', 'list', 'depth', 2, 'ignore', 'globals', 'element', 'Parents:', 'element', 'dill', 'detect', 'parents', 'great_grand_parent', 'list', 'depth', 2, 'ignore', 'globals', 'element']
  Henrietta Ancient One
  Parents:
  Henrietta Ancient One
  </code></pre>
  
  <p>Looking specifically at <code>list</code> objects here, the single <em>referrent</em> (Parent) of <code>great_grand_parent</code> is the string, "Henrietta Ancient One".</p>
  
  <p>And the <em>referrers</em> (Children) (result of <code>gc.get_referrers()</code>, filtered by specified object-type) contains two objects: A <code>list</code> that includes the string 'Henrietta Ancient One', and the <code>string</code> Henrietta Ancient One. (depth=2 and depth=1 return the same result.)</p>
  
  <p>How can I make an object for which Dill can return:</p>
  
  <ol>
  <li>Two distinct depths of referrers</li>
  <li>Two distinct depths of referents</li>
  </ol>