def describeObj(obj, depth=4, path=None, ignore=None):
 if (path is None):
  path = [obj]
 if (ignore is None):
  ignore = {}
 ignore[id(sys._getframe())] = None
 ignore[id(path)] = None
 gc.collect()
 refs = gc.get_referrers(obj)
 ignore[id(refs)] = None
 printed = False
 for ref in refs:
  if (id(ref) in ignore):
   continue
  if (id(ref) in list(map(id, path))):
   print(('Cyclic reference: ' + refPathString(([ref] + path))))
   printed = True
   continue
  newPath = ([ref] + path)
  if (len(newPath) >= depth):
   refStr = refPathString(newPath)
   if ('[_]' not in refStr):
    print(refStr)
   printed = True
  else:
   describeObj(ref, depth, newPath, ignore)
   printed = True
 if (not printed):
  print(('Dead end: ' + refPathString(path)))

def describeObj ( obj , depth = 4 , path = None , ignore = None ) : if ( path is None ) : path = [ obj ] if ( ignore is None ) : ignore = { } ignore [ id ( sys . _getframe ( ) ) ] = None ignore [ id ( path ) ] = None gc . collect ( ) refs = gc . get_referrers ( obj ) ignore [ id ( refs ) ] = None printed = False for ref in refs : if ( id ( ref ) in ignore ) : continue if ( id ( ref ) in list ( map ( id , path ) ) ) : print ( ( 'Cyclic reference: ' + refPathString ( ( [ ref ] + path ) ) ) ) printed = True continue newPath = ( [ ref ] + path ) if ( len ( newPath ) >= depth ) : refStr = refPathString ( newPath ) if ( '[_]' not in refStr ) : print ( refStr ) printed = True else : describeObj ( ref , depth , newPath , ignore ) printed = True if ( not printed ) : print ( ( 'Dead end: ' + refPathString ( path ) ) )
trace all reference paths backward .