python 3's adoption
Daniel Fetchinson
fetchinson at googlemail.com
Wed Jan 27 10:26:37 EST 2010
>>>>> * Print is now a function. Great, much improvement.
>>> Actually not, IMHO. All it does is is to provide incompatibility.
>>
>>
>> What incompatibility are you exactly talking about?
>>
>> 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
>>
>> Yes, this is with python 2.6.2 which is in the 2.x line of releases. So?
>
> I gather that your example is about code that technically executes fine with
> both versions and produces the same result, i.e. that there is a subset with
> the
> same syntax and semantics.
>
> But 'print' calls that technically execute fine with both versions may and
> will
> in general produce different results.
>
> I.e. not just the syntax but also the semantics have changed:
>
>
> >>> import sys
> >>> sys.version
> '2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)]'
> >>>
> >>> print( "2+2 =", 2+2 )
> ('2+2 =', 4)
> >>> _
>
>
> >>> import sys
> >>> sys.version
> '3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)]'
> >>>
> >>> print( "2+2 =", 2+2 )
> 2+2 = 4
> >>> _
True. However, as someone else pointed out in a neighbouring thread you can do
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.
>>> from __future__ import print_function
>>> print( "2+2 =", 2+2 )
2+2 = 4
>>>
which gives 100% compatibility as far as print is concerned between 2.6 and 3.x.
So again, what sort of an incompatibility are you talking about
concerning 'print' between 2.6 and 3.x?
Cheers,
Daniel
--
Psss, psss, put it down! - http://www.cafepress.com/putitdown
More information about the Python-list
mailing list