python __main__ and __init__ proper usage
<p>Since I'm rather new to python this particular aspect of language still opaque for me.</p>

<p>So, assume that my project contains many files with code that does stuff and two "service" files: <code>__init__.py</code> and <code>__main__.py</code></p>

<p>In <code>__init__.py</code> there is only:</p>

<pre><code>if __name__ == "__main__":
    import package.__main__
    __main__.main()
</code></pre>

<p>And in <code>__main__.py</code> as follows:</p>

<pre><code>import package # ok
import package2 # ok

def main():
    package.myfunc1() # can't find reference to myfunc1
    package2.myfunc2() # can't find reference to myfunc2
</code></pre>

<p>So my question is: why both packages are visible while functions inside are not? I've read some source code from google and still can't spot the difference between it and my code. I'm using <code>Python 3.5.1</code></p>

<p>I assume, that code in <code>__init__</code> will launch <code>__main__</code> and <code>__main__</code> will launch the rest of my functions.</p>

<p><strong>UPD</strong> </p>

<p>Well, my apologies if I confused someone with my code. 
The idea that stand behind <code>__init__.py</code> is that file was created by IDE when the first package was added so I decided to fill it with <a href="https://github.com/Sveder/pyweek_18_game/blob/100dd6197962508a78172c0945b9c914040bda7b/byte/byte/__init__.py" rel="noreferrer">code</a> found on first github entry(my fault, I though it can be re-used by copy-paste). </p>

<p>Strictly speaking I just need python construction, that equivalent this C code:</p>

<pre><code>header.h
void func1(){...} //in code1.c
void func2(){...} //in code2.c
#include "header.h"
int main() //in main.c 
{
    func1();
    func2();
    return 0;
}
</code></pre>

<p>And the following code </p>

<pre><code>import package
import package2 

if __name__ == "__main__":
    package.myfunc1() 
    package2.myfunc2() 
</code></pre>

<p>has exactly same issue that stated above, so the matter is not in <code>__init__.py</code></p>