Importing class from another file
<p><strong>Before you mark it as  duplicate</strong> please read my problem:</p>
<p>I am trying to import a class from a file from a subdirectory</p>
<pre><code>&gt; main.py
&gt; ---&gt;folder/
&gt; -----&gt;file.py
</code></pre>
<p>and in <code>file.py</code> i have a class imlpemented ( <code>Klasa</code>)
What have I tried:</p>
<p>putting in main.py:</p>
<pre><code>from folder import file
from file import Klasa
</code></pre>
<p>I am getting the error:</p>
<blockquote>
<p>from file import Klasa</p>
<p>ImportError: No module named 'file'</p>
</blockquote>
<p>When I try to use just:</p>
<pre><code>from folder import file
</code></pre>
<p>I get this error:</p>
<blockquote>
<p>tmp = Klasa()</p>
<p>NameError: name 'Klasa' is not defined</p>
</blockquote>
<p>I have put an empty <code>__init__.py</code> in the subfolder and it still does not work, and I have put in the <code>__init__.py</code>  : <code>from file import Klasa</code> and still doesnt work.</p>
<p>If main and file are in the same folder this work:</p>
<p><code>from file import Klasa</code></p>
<p>but i want them to be in separate files.</p>
<p>Can someone tell me what i am doing wrong?</p>