How to import a function from a module in the same folder?
<p>I am trying to separate my script into several files with functions, so I moved some functions into separate files and want to import them into one main file. The structure is:</p>

<pre><code>core/
  main.py
  posts_run.py
</code></pre>

<p><code>posts_run.py</code> has two functions, <code>get_all_posts</code> and <code>retrieve_posts</code>, so I try import <code>get_all_posts</code> with:</p>

<pre><code>from posts_run import get_all_posts
</code></pre>

<p>Python 3.5 gives the error:</p>

<pre><code>ImportError: cannot import name 'get_all_posts'
</code></pre>

<p>Main.py contains following rows of code:</p>

<pre><code>import vk
from configs import client_id, login, password
session = vk.AuthSession(scope='wall,friends,photos,status,groups,offline,messages',   app_id=client_id, user_login=login,
                     user_password=password)
api = vk.API(session)
</code></pre>

<p>Then i need to import api to functions, so I have ability to get API calls to vk.</p>

<p>Full stack trace</p>

<pre><code>Traceback (most recent call last):
  File "E:/gited/vkscrap/core/main.py", line 26, in &lt;module&gt;
    from posts_run import get_all_posts
  File "E:\gited\vkscrap\core\posts_run.py", line 7, in &lt;module&gt;
    from main import api, absolute_url, fullname
  File "E:\gited\vkscrap\core\main.py", line 26, in &lt;module&gt;
    from posts_run import get_all_posts
ImportError: cannot import name 'get_all_posts'
</code></pre>

<p>api - is a <code>api = vk.API(session)</code> in main.py.
absolute_url and fullname are also stored in main.py.
I am using PyCharm 2016.1 on Windows 7, Python 3.5 x64 in virtualenv.
How can I import this function?</p>