title: Python3 correct way to import relative or absolute?
body: <p>I am writing a python module <em>neuralnet</em>. It was working all fine in Python2, but in Python3 imports are failing.</p>
  <p>This is my code structure.</p>
  <pre><code>neuralnet/
      __init__.py
      train.py         # A wrapper to train (does not define new things)
      neuralnet.py     # Defines the workhorse class neuralnet
      layer/
          __init__.py
          inlayer.py       # Defines input layer class
          hiddenlayer.py
  
  application/         # A seperate application (not part of the package)
     classify.py       # Imports the neuralnet class from neuralnet.py
  </code></pre>
  <p><code>train.py</code> needs to import neuralnet.py's <code>neuralnet</code> class.</p>
  <p><code>neuralnet.py</code> needs to import <code>layers/inlayer.py</code> etc.</p>
  <p>(I prefer relative imports.)</p>
  <p>I have a different application (<code>classify.py</code>) which needs to import this module.
  Where I do...</p>
  <pre><code>from neuralnet.neuralnet import neuralnet
  </code></pre>
  <p>I have tried a few ways to import.
  Either I get an error (mostly arcane like parent is not imported)</p>
  <ol>
  <li><p>While running train.py (which is a part of the neuralnet module)</p>
  <pre><code>from . import layer  # In file neuralnet.py
  SystemError: Parent module '' not loaded, cannot perform relative import
  </code></pre>
  </li>
  </ol>
  <p>Or</p>
  <ol start="2">
  <li><p>while running classify.py (which is outside the module).</p>
  <pre><code>from layer.inlayers import input_layer   # In file neuralnet.py
  ImportError: No module named 'layer'
  </code></pre>
  </li>
  </ol>
  <p>My imports worked perfectly well for years in Python2. I am wondering what Python3 expects of me? Should I move <code>train.py</code> to outside my module (technically it is not a part of the module)? Please suggest best practice.</p>