title: How to import from the same package
body: <p>I'm using <code>Python 3</code> and <code>Jupyter</code> under <code>Windows 10</code>.</p>
  
  <p>I have 2 modules: <code>mod_main</code> and <code>mod_sub</code>. I'd like to import various modules (in this case, only <code>os</code>) from <code>mod_sub</code> to <code>mod_main</code>. The approach that works for me is as follows:</p>
  
  <p><strong>mod_main.py</strong></p>
  
  <pre><code>from pathlib import Path # works with / for any OS
  import sys
  sys.path.append(str(Path('C:/MyApps/Python_Base')))
  from dummypackage.mod_sub import *
  #from dummypackage import mod_sub
  def print_path():
      print(os.path.realpath(__file__))
  </code></pre>
  
  <p><strong>mod_sub.py</strong></p>
  
  <pre><code>import os
  print('mod_sub is imported')
  </code></pre>
  
  <p>I then run the following from a Jupyter Notebook under <code>C:\MyApps\Python_Base</code></p>
  
  <pre><code>from dummypackage import mod_main
  import importlib
  importlib.reload(mod_main)
  mod_main.print_path()
  </code></pre>
  
  <p>Now, I have a couple of questions:</p>
  
  <ol>
  <li>use of wildcards is <a href="https://docs.quantifiedcode.com/python-anti-patterns/maintainability/from_module_import_all_used.html" rel="nofollow noreferrer">discouraged</a>, but if I use <code>from dummypackage import mod_sub</code> then I won't get access to other imported modeules (<code>os</code> in this case). So, what is the best practice here? </li>
  <li>is there any better ways to import a module from the same package? what I did to add the path to the parent folder and the import from package.module looks ugly. Is there a better way to do so? </li>
  </ol>