myths about python 3

Stefan Behnel stefan_ml at behnel.de
Wed Jan 27 11:40:27 CET 2010


Daniel Fetchinson, 27.01.2010 11:32:
> 1. Print statement/function creates incompatibility between 2.x and 3.x!
> 
> Certainly false or misleading, if one uses 2.6 and 3.x the
> incompatibility is not there. Print as a function works in 2.6:
> 
> Python 2.6.2 (r262:71600, Aug 21 2009, 12:23:57)
> [GCC 4.4.1 20090818 (Red Hat 4.4.1-6)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> print( 'hello' )
> hello
> >>> print 'hello'
> hello

This is actually misleading by itself, as the first statement is not a
function call in Py2:

    Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
    [GCC 4.4.1] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> print(1,2)
    (1, 2)

It can, however, be made a function call through a future import in 2.6:

    >>> from __future__ import print_function
    >>> print(1,2)
    1 2

Stefan



More information about the Python-list mailing list