I wasn't feeling very productive today so decided to take a look at Python 3.2 and specifically understand how hard would it be to create a development environment not affecting Python 2.6 related stuff and also how much time would it take to port a simple 2.x script to 3.x.
Luckily, Python 3.x is available in FreeBSD ports tree and, moreover, it doesn't conflict with python2.x stuff, so all I had to do is to cd /usr/ports/lang/python32 && sudo make install clean (actually I've spotted a minor problem with the port, but it doesn't affect anything, for me at least). Viola, it's already there.
Then I decided to pick some simple script and see how much effort it will take to make it run with 3.2. A script that I created some time ago to parse urbandictionary's output seemed like a good fit for this task.
I've ran 2to3 over my old script and it generated a patch which I successfully applied. Apart from that I had to fix bytes/string problem (not really hard and there are lots of information on it on the net) and my script just worked!
So it looks like things are not very hard with 2-to-3 migration. Obviously, things are harder for the larger projects, but with larger projects everything is harder anyway.
The only thing I haven't figured out yet is how to have different versions of easy_install for both 2.6 and 3.2 on FreeBSD, though I haven't spent much time digging into it.
PS I went further with the urbandictionary script, created a package for it, uploaded on PyPI, improved formatting and made it easier to use from python. Here's a screenshot:
Check it out on github if you're interested.
No comments:
Post a Comment