title: Avoid duplicate name when importing a sub-module with only one public member from a package
body: <h2>Basic Setup</h2>
  
  <p>Suppose I want to create a class named <code>Foo</code>. I may create a file like so:</p>
  
  <p><strong>foo.py</strong>:</p>
  
  <pre><code>class Foo:
      def __init__(self):
          self.data = "world"
      def print(self):
          print("Hello, " + self.data)
  </code></pre>
  
  <p>To utilize this class in my main script:</p>
  
  <p><strong>main.py</strong></p>
  
  <pre><code>import foo
  
  test = foo.Foo()
  test.print()
  </code></pre>
  
  <p>Having to type <code>foo.Foo()</code> every time I instantiate the class already feels ridiculous enough, but it gets worse when I want to organize my code by separating my classes into a package:</p>
  
  <p><strong>classes/__init__.py</strong></p>
  
  <pre><code># Empty
  </code></pre>
  
  <p><strong>classes/foo.py</strong></p>
  
  <pre><code># Copy of foo.py, above
  </code></pre>
  
  <p><strong>main.py</strong></p>
  
  <pre><code>import classes.foo
  
  test = classes.foo.Foo()
  test.print()
  </code></pre>
  
  <h2>Simple Answer</h2>
  
  <p>I know I can clean this up somewhat by using <code>from X import Y</code> like so:</p>
  
  <pre><code>from classes.foo import Foo
  
  test = Foo()
  </code></pre>
  
  <h2>Preferred Answer</h2>
  
  <p>Because the file <code>foo.py</code> contains <strong><em>only one</em></strong> member whose name matches the file, I would prefer if I could do something like the following:</p>
  
  <pre><code>from classes import Foo
  # Or:
  import classes.Foo as Foo
  
  test = Foo()
  </code></pre>
  
  <p>Is there a way to do this? Maybe with some code in my <code>__init__.py</code>?</p>