def co_findloadednames(co):
 names = {}
 names.update(co_code_findloadednames(co))
 for c in co.co_consts:
  if isinstance(c, type(co)):
   names.update(co_findloadednames(c))
 return names

def co_findloadednames ( co ) : names = { } names . update ( co_code_findloadednames ( co ) ) for c in co . co_consts : if isinstance ( c , type ( co ) ) : names . update ( co_findloadednames ( c ) ) return names
find all loaded names in a code object and all its consts of code type .