title: How do I make "from directory import outer-directory" work within Python?
body: <p>I'm following this tutorial to build a user login system within Flask using Python 2.7.</p>
  
  <p><a href="http://code.tutsplus.com/tutorials/intro-to-flask-signing-in-and-out--net-29982" rel="nofollow">Intro to Flask: Signing In and Out</a></p>
  
  <p>I have this Flask application structure.</p>
  
  <pre><code>flaskapp/
  └── app/
          ├── user/
          │      ├── __init__.py
          │      ├── static/
          │      ├── templates/
          │      ├── forms.py
          │      ├── routes.py
          └── runserver.py
  </code></pre>
  
  <p>Within the tutorial, it has me edit this file.</p>
  
  <pre><code>app/intro_to_flask/routes.py
  </code></pre>
  
  <p>Within that file you have this code.</p>
  
  <pre><code>from user import app
  from flask import render_template, request, flash
  from forms import ContactForm
  from flask.ext.mail import Message, Mail
  
  mail = Mail()
  .
  .
  .
  # @app.route() mappings start here
  </code></pre>
  
  <p>I get this error.</p>
  
  <pre><code>ImportError: cannot import name app
  </code></pre>
  
  <p>That being said, I cannot do from user import app. I've tried:</p>
  
  <pre><code>from . import app
  </code></pre>
  
  <p>I don't really know how to explain the question here, but I am editing a python file within the user directory that is trying to import an outer directory within itself? How can you possibly do from user import app if the app directory does not live within the user directory? What am I missing here?</p>
  
  <p>Within the runserver.py, I'm able to do it because I assume runserver.py lives in the app directory. I cannot do it in routes.py though.</p>
  
  <p>If I cannot import app, I cannot define routes within Flask as such:</p>
  
  <pre><code>@app.route('/')
  def index():
      return "Testing route!"
  </code></pre>