Nav links

Tuesday, 17 February 2009

RealToMp3 updated to Python 3

I have updated my RealToMp3 script to work in Python 3 rather than Python 2. I also added a percentage download indicator for podcasts, and added support for downloading rtsp:// links. This last feature is useful is you are interested in programming linked from The Beebotron - RealToMp3 makes it easy to set up a weekly scheduled download task. Although much BBC radio is available in convenient podcast form, there are some programs that haven't yet made the switch.

Interestingly, Python 3 is not compatible with Python 2. However, the changes are well-documented and eminently sensible. I'm particularly fond of the new print function, which I find much easier to understand. I wish PHP would make a similar incompatible upgrade, to tidy and reorganise their somewhat muddled current language and library situation.

A trap for new players


I expected that the sample scripts shipping with Python 3 would actually work in Python 3. So, when I found my favourite regular expression tester, \Python\Tools\Scripts\redemo.py, did not work I thought it was a faulty installation. The error was: ImportError: No module named Tkinter In fact, it turned out that the Tkinter library had been renamed (well, re-cased) tkinter in Python 3. Simply changing that in the top of the script fixed it.