module name in sys.modules and globals()
<p>If I import a module, the module name shows up in both <code>sys.modules</code> and <code>globals()</code>. If I again delete it, it is removed from <code>globals()</code>, but still resides in <code>sys.modules</code>. Why is it so?</p>

<pre><code>import mymodule
'mymodule' in globals()   # True
'mymodule' in sys.modules # True
del mymodule
'mymodule' in globals()   # False
'mymodule' in sys.modules # Still True, why?
</code></pre>

<p>I also found the following difference:</p>

<pre><code>from mypackage import mymodule
'mypackage' in sys.modules            # True
'mymodule'  in sys.modules            # False !
'mypackage.mymodule' in sys.modules   # also True !
</code></pre>

<p>while the answers are complementary for <code>globals()</code>:</p>

<pre><code>'mypackage' in sys.modules            # False
'mymodule'  in sys.modules            # True 
'mypackage.mymodule' in sys.modules   # False
</code></pre>
