how can i control modules in package to import in python?
<p>Consider an example,</p>

<p>I have a package having list of modules:</p>

<pre><code> /mypackage/
   __init__.py
   mod1.py
   mod2.py
   mod3.py
</code></pre>

<p><code>prog1.py</code>: I would like to allow only <code>mod2</code> here
<code>prog2</code>: allow <code>mod1,2</code></p>

<p>If I write,</p>

<pre><code>prog1.py
import mypackage
# only mod2 should import

prog2.py
import mypackage
# only mod1,mod3 should import
</code></pre>

<p>How can I restrict at package or module level?</p>

<pre><code>from mypackage import mod2
</code></pre>

<p>or</p>

<pre><code>from mypackage import mod1, mod3
</code></pre>

python