Skip to content
Myr

Added notes on Python 3

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 2c9c269 · Browse files · 4 files+64 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+64 added−9 removed

  • other:+64 added−9 removed

4 files+64 added−9 removed

modified:docs/advanced_foreword.rst+9 added-8 removed
50 unmodified lines
5152Currently the Python community is in the process of improving libraries to53support the new iteration of the Python programming language. While the54situation is greatly improving there are still some issues that make it55hard for us to switch over to Python 3 just now. These problems are55hard for users to switch over to Python 3 just now. These problems are56partially caused by changes in the language that went unreviewed for too57long, partially also because we have not quite worked out how the lower-58level API should change to account for the Unicode differences in Python 3.5960Werkzeug and Flask will be ported to Python 3 as soon as a solution for61the changes is found, and we will provide helpful tips how to upgrade62existing applications to Python 3. Until then, we strongly recommend63using Python 2.6 and 2.7 with activated Python 3 warnings during64development. If you plan on upgrading to Python 3 in the near future we65strongly recommend that you read `How to write forwards compatible66Python code <http://lucumr.pocoo.org/2011/1/22/forwards-compatible-python/>`_.60We strongly recommend using Python 2.6 and 2.7 with activated Python 361warnings during development. If you plan on upgrading to Python 3 in the62near future we strongly recommend that you read `How to write forwards63compatible Python code64<http://lucumr.pocoo.org/2011/1/22/forwards-compatible-python/>`_.6566If you do want to dive into Python 3 already have a look at the67:ref:`python3_support` page.6869Continue to :ref:`installation` or the :ref:`quickstart`.
modified:docs/contents.rst.inc+1 added
51 unmodified lines
52 security53 unicode54 extensiondev55 styleguide56 python357 upgrading58 changelog59 license
modified:docs/installation.rst+2 added-1 removed
12 unmodified lines
13could do that, but the most kick-ass method is virtualenv, so let's have a look14at that first.1516You will need Python 2.6 or higher to get started, so be sure to have an17up-to-date Python 2.x installation. Python 3.x is not supported.17up-to-date Python 2.x installation. For using Flask with Python 3 have a18look at :ref:`python3-support`.1920.. _virtualenv:2122virtualenv
151 unmodified lines
added:docs/python3.rst+52 added
1.. _python3_support:23Python 3 Support4================56Flask and all of its dependencies support Python 3 so you can in theory7start working on it already. There are however a few things you should be8aware of before you start using Python 3 for your next project.910API Stability11-------------1213Some of the decisions made in regards to unicode and byte untilization on14Python 3 make it hard to write low level code. This mainly affects WSGI15middlewares and interacting with the WSGI provided information. Werkzeug16wraps all that information in high-level helpers but some of those were17specifically added for the Python 3 support and are quite new.1819A lot of the documentation out there on using WSGI leaves out those20details as it was written before WSGI was updated to Python 3. While the21API for Werkzeug and Flask on Python 2.x should not change much we cannot22guarantee that this won't happen on Python 3.2324Few Users25---------2627Python 3 currently has less than 1% of the users of Python 2 going by PyPI28download stats. As a result many of the problems you will encounter are29probably hard to search for on the internet if they are Python 3 specific.3031Small Ecosystem32---------------3334The majority of the Flask extensions, all of the documentation and the35vast majority of the PyPI provided libraries do not support Python 3 yet.36Even if you start your project with knowing that all you will need is37supported by Python 3 you don't know what happens six months from now. If38you are adventurous you can start porting libraries on your own, but that39is nothing for the faint of heart.4041Recommendations42---------------4344Unless you are already familiar with the differences in the versions we45recommend sticking to current versions of Python until the ecosystem46caught up.4748The majority of the upgrade pain is in the lower-level libararies like49Flask and Werkzeug and not in the actual high-level application code. For50instance all of the Flask examples that are in the Flask repository work51out of the box on both 2.x and 3.x and did not require a single line of52code changed.