title: When or why to use relative imports in Python
body: <p>Are there any rules or guidelines concerning when to use relative imports in Python? I see them in use all the time, such as in the Flask web framework. When searching for this topic, I only see articles on how to use relative imports, but not <em>why</em>.</p>
  <p>So is there some special benefit to using:</p>
  <pre><code>from . import x
  </code></pre>
  <p>rather than:</p>
  <pre><code>from package import x
  </code></pre>
  <p>Moreover, I noticed that <a href="https://stackoverflow.com/a/5811548/1918127">a related SO post</a> mentions that relative imports are discouraged. Yet people still continue to use them.</p>