def getPythonContainers(meth):
 containers = []
 containers.append(meth.im_class)
 moduleName = meth.im_class.__module__
 while (moduleName is not None):
  module = sys.modules.get(moduleName, None)
  if (module is None):
   module = __import__(moduleName)
  containers.append(module)
  moduleName = getattr(module, '__module__', None)
 return containers

def getPythonContainers ( meth ) : containers = [ ] containers . append ( meth . im_class ) moduleName = meth . im_class . __module__ while ( moduleName is not None ) : module = sys . modules . get ( moduleName , None ) if ( module is None ) : module = __import__ ( moduleName ) containers . append ( module ) moduleName = getattr ( module , '__module__' , None ) return containers
walk up the python tree from method meth .