def iter_symbols(code):
 for name in code.co_names:
  (yield name)
 for const in code.co_consts:
  if isinstance(const, basestring):
   (yield const)
  elif isinstance(const, CodeType):
   for name in iter_symbols(const):
    (yield name)

def iter_symbols ( code ) : for name in code . co_names : ( yield name ) for const in code . co_consts : if isinstance ( const , basestring ) : ( yield const ) elif isinstance ( const , CodeType ) : for name in iter_symbols ( const ) : ( yield name )
yield names and strings used by code and its nested code objects .