import foo as module
module_name = module.__name__
import_line = 'from %s import (%%s)' % module_name
length = len(import_line) - 3
print(import_line % (',\n' + length * ' ').join([a for a in dir(module) if 
    not re.match('__.*[^_]{2}', a)]))
Tool to help eliminate wildcard imports