title: Absolute import failing in subpackage that shadows a stdlib package name
body: <p>Basically I have a subpackage with the same name as a standard library package ("logging") and I'd like it to be able to absolute-import the standard one no matter how I run it, but this fails when I'm in the parent package.</p>
  
  <p>It really looks like either a bug, or an undocumented behaviour of the new "absolute import" support (new as of Python 2.5).  Tried with 2.5 and 2.6.</p>
  
  <p>Package layout:</p>
  
  <pre><code>foo/
      __init__.py
      logging/
          __init__.py
  </code></pre>
  
  <p>In <code>foo/__init__.py</code> we import our own logging subpackage:</p>
  
  <pre><code>from __future__ import absolute_import
  from . import logging as rel_logging
  print 'top, relative:', rel_logging
  </code></pre>
  
  <p>In <code>foo/logging/__init__.py</code> we want to import the stdlib <code>logging</code> package:</p>
  
  <pre><code>from __future__ import absolute_import
  print 'sub, name:', __name__
  
  import logging as abs_logging
  print 'sub, absolute:', abs_logging
  </code></pre>
  
  <p><strong>Note:</strong> The folder containing <code>foo</code> is in sys.path.</p>
  
  <hr>
  
  <p>When imported from outside/above <code>foo</code>, the output is as expected:</p>
  
  <pre><code>c:\&gt; python -c "import foo"
  sub, name: foo.logging
  sub, absolute: &lt;module 'logging' from 'c:\python26\lib\logging\__init__.pyc'&gt;
  top, relative: &lt;module 'foo.logging' from 'foo\logging\__init__.pyc'&gt;
  </code></pre>
  
  <p>So the absolute import in the subpackage finds the stdlib package as desired.  </p>
  
  <p>But when we're inside the <code>foo</code> folder, it behaves differently:</p>
  
  <pre><code>c:\foo&gt;\python25\python -c "import foo"
  sub, name: foo.logging
  sub, name: logging
  sub, absolute: &lt;module 'logging' from 'logging\__init__.pyc'&gt;
  sub, absolute: &lt;module 'logging' from 'logging\__init__.pyc'&gt;
  top, relative: &lt;module 'foo.logging' from 'c:\foo\logging\__init__.pyc'&gt;
  </code></pre>
  
  <p>The double output for "sub, name" shows that my own subpackage called "logging" is importing itself a second time, and it does not find the stdlib "logging" package <em>even though "absolute_import" is enabled</em>.</p>
  
  <p>The use case is that I'd like to be able to work with, test, etc, this package regardless of what the current directory is.  Changing the name from "logging" to something else would be a workaround, but not a desirable one, and in any case this behaviour doesn't seem to fit with the description of how absolute imports should work.</p>
  
  <p>Any ideas what is going on, whether this is a bug (mine or Python's), or whether this behaviour is in fact implied by some documentation?</p>
  
  <p><strong>Edit:</strong> the answer by gahooa shows clearly what the problem is.  A crude work-around that proves that's it is shown here:</p>
  
  <pre><code>c:\foo&gt;python -c "import sys; del sys.path[0]; import foo"
  sub, name: foo.logging
  sub, absolute: &lt;module 'logging' from 'c:\python26\lib\logging\__init__.pyc'&gt;
  top, relative: &lt;module 'foo.logging' from 'c:\foo\logging\__init__.pyc'&gt;
  </code></pre>