Differences between revisions 4 and 5
Revision 4 as of 2008-12-05 02:32:46
Size: 3053
Comment:
Revision 5 as of 2008-12-05 02:36:10
Size: 3121
Comment:
Deletions are marked like this. Additions are marked like this.
Line 62: Line 62:

= I want to start learning Python. What version should I use? =

What's Python 3000/Python 3.0?

Python 3.0 (a.k.a. "Python 3000" or "Py3k") is a new version of the language that is incompatible with the 2.x line of releases. The language is mostly the same, but many details, especially how built-in objects like dictionaries and strings work, have changed considerably, and a lot of deprecated features have finally been removed. The standard library has also been reorganized in a few prominent places.

What changed in Python 3.0?

Read What's New in Python 3.0, which lists the changes between Python 2.6 and Python 3.0.

What will happen to the Python 2.x versions?

There will be at least one more 2.x release, Python 2.7. 2.7 will

How should I port existing Python code to Python 3.0?

Python 2.6 and 3.0 include a tool called 2to3 that parses Python 2.x code and rewrites it to work in Python 3.0. 2to3 includes a large set of fixers, each one updating a particular language feature.

We suggest the following steps for porting a package to 3.0:

* Have a test suite that exercises significant portions of your library or application's functionality, the more the better.

* Run the 2to3 script over the code. If 2to3 can't perform the conversion due to code constructs that can't be automatically translated, modify your 2.x code to use 3.0-compatible features.

* Once 2to3 can convert your code without complaint, try running the test suite using the 3.0-transformed version. Examine any test failures and modify the 2.x code responsible to be 3.0-compatible until the test suite succeeds using the transformed version.

Consult the 2to3 documentation for more information.

One approach to distributing your 3.0 package is to use 3.0's build_py_2to3 implementation of the build_py command. See Demo/distutils/test2to3 for an example.

You will have a single lib.py, written in 2.x. When you install in 3.0, lib2to3 will convert it to 3.x in the build area, and then install the 3.0 version.

That, of course, requires you to adjust lib.py in such a way that 2to3 will successfully and completely convert it. In two experiments, Martin von Loewis ported Django and Mark Hammond ported PythonWin to 3.0, and found that these adjustments were quite feasible. You look at what 2to3 does, find out what additional modifications need to be done, and apply them to the input of 2to3 so that

* 2to3 leaves these changes in place * they either have no effect or still work correctly when run in 2.x.

In this weblog posting, Guido van Rossum strongly suggests not changing your APIs when porting to 3.0, because API changes will make it difficult for users to tell whether test suite failures are due to the 2.6->3.0 transition or to the API changes.

How do I find out what packages have been ported to 3.0?

XXX have a weblog? have a web page?

I want to start learning Python. What version should I use?

Python3FAQ (last edited 2019-11-09 22:42:59 by FrancesHocutt)

Unable to edit the page? See the FrontPage for instructions.