On Sat, 9 Sep 2017 12:41 am, Chris Angelico wrote: >> I ran 2to3 on some code that worked under 2.6.6. and 3.6.2. 2to3 broke it >> for both versions and it was a fairly trivial script. > > Show the code that it broke? I've never seen this, unless it's > something like "now you need to install third-party package X in > Python 3". The 2to3 transformations are fine for everything in the > stdlib.
Chris, I don't think it is controversial that 2to3 occasionally breaks code, or fails to translate every feature. Even today, there are still the occasional bug report or feature request for 2to3. Even human beings can't always translate 2 to 3 flawlessly, and there are some code bases that actually are tricky to migrate to 3. We shouldn't expect an automated tool to handle *all* code bases perfectly without human review. One thing which is notoriously tricky to migrate is mixed bytes/Latin1 text using Python 2 strings, say you're manipulating file formats that mix text with binary bytes. These mixed binary/text files are sometimes badly suited to the new Unicode/bytes model. (There was some discussion on Python-Ideas about easing the transition. One concrete change that came out of that was to add % formatting to bytes in 3.5, but the rest of the discussion seems to have fizzled out due to lack of interest.) While 2to3 is still an awesome tool, remember that the core developers have changed their recommendation from: # don't do this write your code in Python 2, and use 2to3 to translate to Python 3, keeping two code bases; instead now recommending: # do this instead write a single code base that works in both Python 2.7 and Python 3. >> If you want to encourage people to move from Python 2 to 3 then continue to >> help answer questions when they are Python 2 based. We do. Hell, if somebody wants to ask a question about Python 1.5, I've got a working copy and can probably answer it! But some of us can't resist the temptation to evangelise about Python 3 :-) > Also, be completely honest here: how much work would it take for you > to move your "millions of servers" from Python 2 to, say, PHP? or > Ruby? or C? or JavaScript? Is any of those (or any write-in answer you > wish) actually easier than porting to Python 3? Maybe not easier, but maybe there's some other payoff: - some poor, benighted folks just like Javascript or Ruby better than Python (perhaps they were dropped on the head as babies a few too many times *wink*) - maybe some companies have a glut of cheap PHP code-monkeys they can throw at a problem, and shortage of expensive Python rockstars who make unreasonable demands like "decent working conditions" and "life-work balance"; - perhaps it is worth the increased cost of re-writing your app to get better performance or reliability (or at least somebody thinks so...) -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list