Listing installed modules in Python
<p>Here is a basic code I came up with to list modules installed.</p>

<pre><code>import sys as s
mod=s.modules.keys()
for indx,each in enumerate(mod):
    print indx,each
</code></pre>

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

<pre><code> numpy.f2py.pprint'
 numpy.distutils.atexit'
 numpy.distutils.sys'
 numpy.f2py.sys'
</code></pre>

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