title: Doctest and relative imports
body: <p>I'm having trouble using doctest with relative imports.  The simple solution is just to get rid of the relative imports.  Are there any others?</p>
  
  <p>Say I have a package called example containing 2 files:</p>
  
  <p><strong><code>example/__init__.py</code></strong></p>
  
  <pre><code>"""
  This package is entirely useless.
  &gt;&gt;&gt; arnold = Aardvark()
  &gt;&gt;&gt; arnold.talk()
  I am an aardvark.
  """
  
  from .A import Aardvark
  
  if __name__ == "__main__":
      import doctest
      doctest.testmod()
  </code></pre>
  
  <p><strong>example/A.py</strong></p>
  
  <pre><code>class Aardvark(object):
      def talk(self):
          print("I am an aardvark.")
  </code></pre>
  
  <p>If I now attempt</p>
  
  <pre><code>python example/__init__.py
  </code></pre>
  
  <p>then I get the error</p>
  
  <pre><code>Traceback (most recent call last):
    File "example/__init__.py", line 8, in &lt;module&gt;
      from .A import Aardvark
  ValueError: Attempted relative import in non-package
  </code></pre>