title: python import at same folder
body: <p>If import an file in another file in the same folder.</p>
  
  <p>file structure:</p>
  
  <pre><code>.
  ├── b
  │   ├── c.py
  │   ├── d.py
  │   └── __init__.py
  └── __init__.py
  </code></pre>
  
  <p>in d.py:</p>
  
  <pre><code>import b.c
  print "import successfully"
  </code></pre>
  
  <p><strong>update 1</strong>:</p>
  
  <p>I use both</p>
  
  <pre><code>python d.py
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>python b/d.py
  </code></pre>
  
  <p>the program cannot run and raise a ImportError.</p>
  
  <p>To solve the problem, I use </p>
  
  <pre><code>    sys.path.insert(0, realpath(path_join(dirname(__file__), '../')))
  </code></pre>
  
  <p>However, It doesn't seems like the standard way.</p>
  
  <p>Like some famous project: tornado or some what, always using this structure. but don't have the insert line.</p>
  
  <p>autotest tools such as sniffer, autonose can run such structure if the import sentence is in a unittest file.</p>
  
  <p>I don't know why.</p>
  
  <p>PEP328 or PEP366 don't give me a great solution about this.</p>
  
  <p>PEP8 recommend me to do things like this way.</p>
  
  <p>The question also occur when import another module (in another file)
  such as:</p>
  
  <pre><code>├── a
  │   ├── e.py
  │   └── __init__.py
  ├── b
  │   ├── c.py
  │   ├── d.py
  │   └── __init__.py
  ├── __init__.py
  </code></pre>