Friday, February 01, 2008

Python 3.0 Compatability

I just tried out a beta version of Python 3.0. It looks pretty good so far. I read on Slashdot how it isn't backward compatible, so I figured I'd give it a spin.

I tried a 200 line script I had built with 2.3.4, and the results weren't all that bad, really. don't get me wrong, some work is required to get code to work in 3.0, but I think some people are getting a little too worked up about this.

Minor problems I experienced:

1. It complained a number times about my indentation, namely the mixing of spaces and tabs. This isn't a big deal, because this is a thing that has been long known as being an issue within the development community. Python was just less strict about it in the past.

2. The "print" statement has been changed to be a method (ie. print()). This requires the changing of some code. But then again, a well-designed project shouldn't have print statements liberally scattered all over the place anyways.

3. I've noticed that the way floating point results are presented (in relation to division operations) has changed. Some printed results that formerly were nicely rounded to two decimal points, now have 10 digits to the right of the decimal point.

I also tried running some other code, and I found in my anagram generator that some code related to maps and lambdas isn't working anymore. A good guide to evaluating what changes are present in 3.0 is this.

That's it! I'm pretty impressed. I had low expectations because of all the people potificating over this. But the result is pretty good.

Sure, these issues will be compounded on a big project, but I don't think this is nearly as bad as it sounds. With good development tools, the cost of these changes can be minimized.

My advise is still conservative: If you have a somewhat larger project (over 1000 lines), just stick with 2.x, as it will still be maintained. However, if your project is smaller, or if you are starting a new project, I'd consider using 3.0 instead (once a stable version is released, of course, which should happen towards the end of 2008)

All you Python developers out there, have you made any attempts to run code in 3.0 beta?

Labels: , ,


Post a Comment

<< Home