How to seperate a python file to couple files, making a real game with files
<p>I made a little game with python/pygame. It's in one folder and it's 300+ lines. I want to develop this little game. I'm seeing lots of  games
made by pygame, and I'm seeing they have folders like <code>main.py</code> , <code>classes.py</code> and <code>setup.py</code>.</p>

<p>But I only know the python language and a little pygame. How can I do the file things, or how can I learn?</p>

<p>To import a file called <em>script.py</em> from the same directory as your main file:</p>

<pre><code>import script
</code></pre>

<p>To import a file called <em>script.py</em> from a sub directory called <em>app</em>:</p>

<pre><code>import sys
sys.path.insert('app')
import script
</code></pre>

<p>To import a file called <em>script.py</em> from the parent directory:</p>

<pre><code>import sys
import os
sys.path.insert(0, os.path.abspath('../'))
import script
</code></pre>

<p>To import a file called <em>script.py</em> from a sibling directory called <em>app</em>:</p>

<pre><code>import sys
import os
sys.path.insert(0, os.path.abspath('../app'))
import script
</code></pre>

<p>The methods described above are fine if you need to quickly import a few files, but it is commonly recommended that people use <a href="https://virtualenv.pypa.io/en/stable/" rel="nofollow">virtualenv</a> when handling larger projects.</p>

python pygame