Python - Expression between Python 2.X and Python 3.X

Not Equals

In Python 2.X, value inequality can be written as either X != Y or X <> Y.

In Python 3.X, the latter of these options is removed because it is redundant.

In either version, best practice is to use X != Y for all value inequality tests.

Backquotes expression

In Python 2.X, a backquotes expression `X` works the same as repr(X) and converts objects to display strings.

This expression is removed in Python 3.X, you can use the more readable str and repr built-in functions.


The X // Y floor division expression truncates fractional remainders in both Python 2.X and 3.X.

The X / Y expression performs true division in 3.X (retaining remainders) and classic division in 2.X (truncating for integers).

In Python 2.X, magnitude comparisons of mixed types are allowed.

It converts numbers to a common type, and order other mixed types according to type names.

In Python 3.X, nonnumeric mixed-type magnitude comparisons are not allowed and raise exceptions.

Magnitude comparisons for dictionaries are no longer supported in Python 3.X.

Related Topic