title: Does python do something extra with a multi-segment import?
body: <p>I saw the following in a student's script, and to my surprise it works:</p>
  
  <pre><code>&gt;&gt;&gt; import os.path
  </code></pre>
  
  <p>The question, in brief, is: How is this <strong>different</strong> from simple <code>import os</code>? Or is it the same, except for necessitating that <code>os.path</code> exists?</p>
  
  <p>As you can see below, it doesn't define <code>path</code> in my scope but <code>os</code>. </p>
  
  <pre><code>&gt;&gt;&gt; dir()
  ['__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'os']
  </code></pre>
  
  <p>So the question is: What does python do with this? For sure, it imports (and hence executes) the module <code>os</code>. It also ensures that <code>os.path</code> does resolve to something valid. (Thanks to @Lee and @Stuart for the links to the documentation that confirms it.) But is there more? Or is <code>import pkg.submod</code> always equivalent to <code>import pkg</code> (provided <code>pkg.submod</code> exists)?</p>
  
  <p>If I import <code>os</code>, it already imports/executes any modules that <code>os</code> itself imports; so <code>os.path</code> is already loaded. Are there arrangements (not too exotic) where importing <code>pkg.submod</code> could lead to different code being executed, or in different order, or otherwise having different side effects, than just importing <code>pkg</code>? And are there legitimate use cases for the multi-segment form? (To put it differently: What's the point?)</p>