title: How to import from sibling module in a package?
body: <p>My package has the following structure:</p>
  
  <pre><code>myPackage
   -- __init__.py &lt;-- empty
   -- signal.py
   -- plot.py
  </code></pre>
  
  <p>signal.py contains:</p>
  
  <pre><code>from plot import plot_signal
  
  def build_filter():
     ...
  
  def other_function():
     plot_signal()
  </code></pre>
  
  <p>plot.py contains:</p>
  
  <pre><code>from signal import build_filter
  
  def plot_signal():
     ...
  
  def other_function():
     build_filter()
  </code></pre>
  
  <p>I then have my script that makes use of this package that contains something like:</p>
  
  <pre><code>import myPackage as mp
  
  mp.plot.plot_signal()
  </code></pre>
  
  <p>When I run this I get an attribute error: <code>module 'myPackage' has no attribute 'plot'</code></p>
  
  <p>I'm not sure why its referring to <code>plot</code> as an attribute when its a module in my package, or why its referring to <code>myPackage</code> as a module.</p>
  
  <p>I then tried importing my package and calling the function a different way:</p>
  
  <pre><code>from myPackage import plot, signal
  
  plot.plot_signal()
  </code></pre>
  
  <p>However, now I get an import error: <code>cannot import name 'build_filter'</code> and the traceback is referring to <code>plot.py</code> where its trying to import the <code>build_filter()</code> function from a sibling module.</p>
  
  <p>I'm thinking this has something to do with the fact that the 2 modules are using functions from one another, and recursively importing the other module.</p>
  
  <p>What's the correct way to organize this package so that sibling modules can import functions from each other?</p>