myths about python 3

Daniel Fetchinson fetchinson at googlemail.com
Wed Jan 27 15:30:00 CET 2010


>> 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

Thanks! This is true, luckily you provided a better solution and the
conclusion is not changed, as long as print is concerned, 2.6 and 3.x
can trivially be made compatible.

Surely there are incompatibilities, but first of all there are many
tools that help the transition such as 2to3 and there is a clear and
officially documented migration guide too (quoted by Steve Holden in
another thread not so long ago), second of all the most vocal
arguments that one hears mostly from ill-informed people are related
to print and similar non-issues. These then get quoted over and over
again, which led me to write this post :)

Cheers,
Daniel


Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown



More information about the Python-list mailing list