sys.modules.values()
... если вам действительно нужны имена модулей, используйте sys.modules.keys ()
dir()
не то, что вы хотите.
>>> import re
>>> def foo():
... import csv
... fubar = 0
... print dir()
...
>>> foo()
['csv', 'fubar'] # 're' is not in the current scope
>>>