Explore Flask

Assumptions

In order to present you with more specific advice, I've written this book with a few fundamental assumptions. It's important to keep this in mind when you're reading and applying these recommendations to your own projects.

Audience

The content of this book builds upon the information in the official documentation. I highly recommend that you go through the user guide and follow along with the tutorial. This will give you a chance to become familiar with the vocabulary of Flask. You should understand what views are, the basics of Jinja templating and other fundamental concepts defined for beginners. I've tried to avoid overlap with the information already available in the user guide, so if you read this book first, there's a good chance that you'll find yourself lost (is that an oxymoron?).

With all of that said, the topics in this book aren't highly advanced. The goal is just to highlight best practices and patterns that will make development easier for you. While I'm trying to avoid too much overlap with the official documentation, you may find that I reiterate certain concepts to make sure that they're familiar. You shouldn't need to have the beginner's tutorial open while you read this.

Versions

Python 2 versus Python 3

As I write this, the Python community is in the midst of a transition from Python 2 to Python 3. The official stance of the Python Software Foundation is as follows:

Python 2.x is the status quo, Python 3.x is the present and future of the language.

As of version 0.10, Flask runs with Python 3.3. When I asked Armin Ronacher about whether new Flask apps should begin using Python 3, he said that he's not yet recommending it to people.

I'm not using it myself currently, and I don't ever recommend to people things that I don't believe in myself, so I'm very cautious about recommending Python 3.

Armin Ronacher, creator of Flask

One reason for holding off on Python 3 is that many common dependencies haven't been ported yet. You don't want to build a project around Python 3 only to realize a few months down the line that you can't use packages X, Y and Z. It's possible that eventually Flask will officially recommend Python 3 for new projects, but for now it's all about Python 2.

Note The Python 3 Wall of Superpowers tracks which major Python packages have been ported to Python 3.

Since this book is meant to provide practical advice, I think it makes sense to write with the assumption of Python 2. Specifically, I'll be writing the book with Python 2.7 in mind. Future updates may very well change this to evolve with the Flask community, but for now 2.7 is where we stand.

Flask version 0.10

At the time of writing this, 0.10 is the latest version of Flask (0.10.1 to be exact). Most of the lessons in this book aren't going to change with minor updates to Flask, but it's something to keep in mind nonetheless.