On Sat, 28 May 2011 08:38:54 +0200, Thorsten Kampe wrote: > * Thomas Rachel (Sat, 28 May 2011 07:06:53 +0200) >> Am 27.05.2011 17:52 schrieb Steven D'Aprano: >> > On Fri, 27 May 2011 09:40:53 -0500, harrismh777 wrote: >> >> 3.x is completely incompatible with 2.x (some call it a dialect, but >> >> that is a lie). >> > >> > "Completely incompatible"? A "lie"? >> >> Hard word, but it is true. Many things can and will fall on your feet >> when moving. > > I think we should stop talking about (in)compatability because everyone > seems to associate something different with that term (incompatible = > "no Python2 to code will run with Python3", "not all Python2 code will > run with Python3").
There is a difference between "completely incompatible" and merely "incompatible to some degree". It just takes *one* tiny incompatibility to stop a program running, so "will it run unmodified?" is hardly a good measure of the degree of incompatibility. Python 2.5 and 2.6 are incompatible to some degree. I recently had to port a client's program from 2.3 to 2.6. I did it in two steps: about two hours to get it working in 2.5, then the same to get it working in 2.6, and then about a day of effort to iron out all the display issues in Tkinter (such as text being shown in giant letters). Judging by the binary Yes/No "does it run unmodified?" test, I'd have to say that Python 2.3, 2.5 and 2.6 are "completely different" -- which would be foolish. Nobody sensible applies such a simple-minded, overly strict test to minor releases, or even between major releases like 1.5 versus 2.0. What would be the point? It is not the least bit helpful to learn that your 2.3 code doesn't run unmodified in 2.6. (Learning that it does, on the other hand, is useful. But such code is in a minority.) And yet some people are willing to throw commonsense away and apply such an obviously unsuitable test to Python 3. These people vehemently insist that the differences between Python 2.7 and 3.2 are of the same qualitative kind as between Ruby and PHP (they're *different languages* you see, not merely different dialects of the same language, and anyone who tells you different is not just mistaken but *lying*). > The question is: if you want (or have) to run your code under Python3, > how likely is that it will run unmodified? That's not a useful question. The useful question is to ask how much effort is it to make the code run in the new version. The effort might be zero (but probably isn't), or it might be a minute, or an hour, or a day, or six months... that depends partly on the complexity of your code and partly on the differences between Python 2.x and 3.x. A trivial app might take three minutes to port from Python 2.5 to 3.2. A complicated app might take three months to port from 2.5 to 2.6. What generalization do we make from this? > My experience is: unless the > code is especially written with Python3 compatability or just a short > snippet, it's actually quite unlikely that it will run. You describe taking a full day to upgrade a 150 line PyQt application. Only it wasn't a 150 line application, was it? By your own admission, much of the problems were in the library, PyQt, so it was more like 150,000 lines. (Or whatever the size of PyQt is...) Rather than "it took a full day to upgrade 150 lines to use Python 3, that's terrible!", it is more like "it only took a day to upgrade my 150 line app *and* work around a whole lot of problems with a huge library, that's really great!" -- Steven -- http://mail.python.org/mailman/listinfo/python-list