Masquerading real module of a class
<p>Suppose you have the following layout for a python package</p>

<pre><code>./a
./a/__init__.py
./a/_b.py
</code></pre>

<p>inside <code>__init__.py</code> you have</p>

<pre><code>from _b import *
</code></pre>

<p>and inside _b.py you have</p>

<pre><code>class B(object): pass
</code></pre>

<p>If you import from interactive prompt </p>

<pre><code>&gt;&gt;&gt; import a
&gt;&gt;&gt; a.B
&lt;class 'a._b.B'&gt;
&gt;&gt;&gt;
</code></pre>

<p>How can I completely hide the existence of _b ?</p>

<p>The problem I am trying to solve is the following: I want a facade package importing "hidden" modules and classes. The classes available from the facade (in my case <code>a</code>) are kept stable and guaranteed for the future. I want, however, freedom to relocate classes "under the hood", hence the hidden modules. This is all nice, but if some client code pickles an object provided by the facade, this pickled data will refer to the hidden module nesting, not to the facade nesting. In other words, if I reposition the <code>B</code> class in a module <code>_c.py</code>, client codes will not be able to unpickle because the pickled classes are referring to <code>a._b.B</code>, which has been moved. If they referred to <code>a.B</code>, I could relocate the B class as much as I want under the hood, without ruining pickled data.</p>
