官术网_书友最值得收藏!

Why Python 3?

While the development of Python 3 started in 2006, its first release, Python 3.0, was released on December 3, 2008. The main reasons for a backward incompatible version were: switching to Unicode for all strings, increased use of iterators, cleanup of deprecated features such as old-style classes, and some new syntactic additions such as the nonlocal statement.

The reaction to Python 3 in the Django community was rather mixed. Even though the language changes between version 2 and 3 were small (and over time, reduced), porting the entire Django codebase was a significant migration effort.

On February 13, Django 1.5 became the first version to support Python 3. Core developers have clarified that, in future, Django will only be written for Python 3.

For this book, Python 3 is ideal for the following reasons:

  • Better syntax: This fixes a lot of ugly syntaxes, such as izip, xrange, and __unicode__, with the cleaner and more straightforward zip, range, and __str__.
  • Sufficient third-party support: Of the top 200 third-party libraries, more than 90 percent have Python 3 support (see Python 3 Wall of Superpowers).
  • No legacy code: We are creating a new project, rather than dealing with legacy code that needs to support an older version.
  • Default in modern platforms: This is already the default Python interpreter in Arch Linux. Ubuntu and Fedora plan to complete the switch in a future release.
  • It is easy: From a Django development point of view, there are very few changes, and they can all be learned in a few minutes.

The last point is important. Even if you are using Python 2, this book will serve you fine. Read Appendix A to understand the changes. You will need to make only minimal adjustments to backport the example code to Python 2.

主站蜘蛛池模板: 昌邑市| 富裕县| 蓬安县| 喀喇沁旗| 莱西市| 茶陵县| 会泽县| 南阳市| 仁寿县| 厦门市| 榆社县| 望奎县| 儋州市| 金华市| 舒城县| 灌云县| 庄河市| 玉门市| 剑河县| 伊川县| 乌兰浩特市| 襄汾县| 康定县| 突泉县| 盈江县| 额尔古纳市| 西宁市| 湄潭县| 铁岭县| 即墨市| 孟州市| 红河县| 海淀区| 兴和县| 济宁市| 什邡市| 旬邑县| 武乡县| 北宁市| 大同市| 岳西县|