Listing installed modules in Python
Question: Here is a basic code I came up with to list modules installed.

    
    
    import sys as s
    mod=s.modules.keys()
    for indx,each in enumerate(mod):
        print indx,each
    

But what I am looking for is, it should only print out the parent module name
like for

    
    
     numpy.f2py.pprint'
     numpy.distutils.atexit'
     numpy.distutils.sys'
     numpy.f2py.sys'
    

It should count it once as Numpy and move to look for next module and repeat
same way...


Answer: 
    import sys
    print set([each.split('.')[0] for each in sys.modules.keys()])
    

