What 2to3 latches produce valid Python 2 code?

2to3 is a Python program that reads the source code of Python 2.x and uses a series of latches to convert it to actual Python 3.x code.

Consider the forty fixes listed at https://docs.python.org/3.4/library/2to3.html#fixers . By design, they all output valid Python 3 code. What output code is valid for Python 2?

For example, the NE of an element that "converts the old unequal syntax <>into !=" has this property because !=Python 2 as well as Python 3 are valid.

While the NONZERO latch, which "renames __nonzero__to __bool__", does not have this property, because in Python 2.7 there is no function __bool__.

+5
source share
1 answer

What's New in Python 3.0 :

, Python 2.6 3.0; , , , . , Python 2.6, Python 3.0, 3, 2.6 2to3, 3.0 .

, 3.0.

, , , , - Six, , , . , , , , .

, Python 3.x , , 3.x 2.x - . Python 2 Python 3. , Python 3 ( Python 3 - , , Python 2 int ). , , .

Python 3 2to3 2to3 , , , , , , Python 2.x.

+1

All Articles