Prev: Ad hoc lists vs ad hoc tuples
Next: Python and Ruby
From: Daniel Fetchinson on 27 Jan 2010 05:32 Hi folks, I was going to write this post for a while because all sorts of myths periodically come up on this list about python 3. I don't think the posters mean to spread false information on purpose, they simply are not aware of the facts. My list is surely incomplete, please feel free to post your favorite misconception about python 3 that people periodically state, claim or ask about. 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 >>> 2. Integer division creates incompatibility between 2.x and 3.x! Again false or misleading, because one can get the 3.x behavior with 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. >>> 6/5 1 >>> from __future__ import division >>> 6/5 1.2 Please feel free to post your favorite false or misleading claim about python 3! Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown
From: Stefan Behnel on 27 Jan 2010 05:40 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
From: Andre Engels on 27 Jan 2010 05:45 On Wed, Jan 27, 2010 at 11:32 AM, Daniel Fetchinson <fetchinson(a)googlemail.com> wrote: > Hi folks, > > I was going to write this post for a while because all sorts of myths > periodically come up on this list about python 3. I don't think the > posters mean to spread false information on purpose, they simply are > not aware of the facts. > > My list is surely incomplete, please feel free to post your favorite > misconception about python 3 that people periodically state, claim or > ask about. > > 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 >>>> > > > 2. Integer division creates incompatibility between 2.x and 3.x! > > Again false or misleading, because one can get the 3.x behavior with 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. >>>> 6/5 > 1 >>>> from __future__ import division >>>> 6/5 > 1.2 > > > Please feel free to post your favorite false or misleading claim about python 3! Well, I see two false or misleading claims just above - namely that the two claims above are false or misleading. They tell just half of the story, and that half is indeed easy. A Python 3 program can be unchanged (in the case of print) or with only trivial modifications (in the case of integer division) be made to run on Python 2.6. The other way around this is _not_ the case. To say that two things are compatible if one can be used for the other, but the other not for the first, is false or misleading. -- André Engels, andreengels(a)gmail.com
From: Daniel Fetchinson on 27 Jan 2010 09:22 >> Hi folks, >> >> I was going to write this post for a while because all sorts of myths >> periodically come up on this list about python 3. I don't think the >> posters mean to spread false information on purpose, they simply are >> not aware of the facts. >> >> My list is surely incomplete, please feel free to post your favorite >> misconception about python 3 that people periodically state, claim or >> ask about. >> >> 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 >>>>> >> >> >> 2. Integer division creates incompatibility between 2.x and 3.x! >> >> Again false or misleading, because one can get the 3.x behavior with 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. >>>>> 6/5 >> 1 >>>>> from __future__ import division >>>>> 6/5 >> 1.2 >> >> >> Please feel free to post your favorite false or misleading claim about >> python 3! > > Well, I see two false or misleading claims just above - namely that > the two claims above are false or misleading. They tell just half of > the story, and that half is indeed easy. A Python 3 program can be > unchanged (in the case of print) or with only trivial modifications > (in the case of integer division) be made to run on Python 2.6. Okay, so we agree that as long as print and integer division is concerned, a program can easily be written that runs on both 2.6 and 3.x. My statements are exactly this, so I don't understand why you disagree. > The other way around this is _not_ the case. What do you mean? > To say that two things are > compatible if one can be used for the other, but the other not for the > first, is false or misleading. I'm not sure what you mean here. Maybe I didn't make myself clear enough, but what I mean is this: as long as print and integer division is concerned, it is trivial to write code that runs on both 2.6 and 3.x. Hence if someone wants to highlight incompatibility (which surely exists) between 2.6 and 3.x he/she has to look elsewhere. Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown
From: Daniel Fetchinson on 27 Jan 2010 09:30
>> 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 |