# find /Library/Frameworks/Python.framework/Versions/Current/lib/python2.4/ -name "*.py" -exec grep "import" {} ¥; >allimport.txt
infile = file('allimport.txt', 'rb').read()
import re
ptn1 = re.compile(r'^¥s*import (.+)$', re.M)
ptn2 = re.compile(r'^¥s*from (.+) import .+$', re.M)
mods = [mod.strip() for mod in ','.join(ptn1.findall(infile)).split(',')] + ¥
  [mod.strip() for mod in ','.join(ptn2.findall(infile)).split(',')]
count = {}
for m in mods:
  if not count.has_key(m):
    count[m] = 0
  count[m] += 1
print sorted(count.items(), key=lambda k: k[1], reverse=True)
-----------------
[('pytz.tzinfo', 1577), ('sys', 1271), ('os', 975), ('types', 689), ('string', 516), ('time', 360), ('unittest', 358), ('re', 310), ('wx', 282), ('test', 205), ('Pythoncard', 203), ('Numeric', 198), ...