How to get the list of imported variables/functions

Michael Hudson mwh21 at
Tue May 2 13:56:54 EDT 2000

"Emile van Sebille" <emile at> writes:

> >>> a = dir()
> >>> from string import *
> >>> b = dir()
> >>> for each in b:
>  if not (each in a):
>   print each

> I couldn't get Mike's sys.module['imported_mod'].keys() to work,
> and dir() of import * type thing doesn't do it.

Ah, that's probably because I used a string method; try

filter(lambda s:s[1]<>'_',sys.module['imported_mod'].keys())


  nonono,  while we're making wild  conjectures about the behavior 
  of completely  irrelevant tasks,  we must not  also make serious 
  mistakes, or the data might suddenly become statistically valid.
                                      -- Erik Naggum, comp.lang.lisp

More information about the Python-list mailing list