Tag Archives: python

Playing with Python: Starting off with anagrams

3 Jun

I’m really into Python this summer, and thought I might share some of my work. I started off with a (simple enough) web application to connect to MySQL on Fedora 12, trying to make a cricket statistics site. It went off pretty well, but I got pretty bored and went off to do an Anagram generator. This morning I started off, with a basic tool to check if two strings are anagrams of one another.

The flow I thought of was:

1. Remove spaces from the strings, and sort them in ascending order.

2. Compare the sorted strings to see if they are equal. The two steps can be done in a single line.


return sorted(list(in1)) == sorted(list(in2))

This will show if the two strings are anagrams of each other.

I need to create a dictionary of words, and then think of a way to get the major anagram generation part going. I hope to complete that over the weekend. I also hope to check my code on Python 2 and 3, using Fedora 13′s parallel installable stacks.

A month of Fedora 12

5 Dec

To be frank, I’ve been using Fedora 12 since the latter half of October from the release candidates, and it is a surprise that there has not been a single issue. There were bugs in the Fedora 11 anaconda installer, and I didn’t like the wallpaper as much as the older ones. But I just love the default Leonidas wallpaper, and many other UI quirks don’t exist, at least for me.

I had installed the release candidates from 1 to 4, and thereon, updated from release candidate 4 to final release two days after November 17. Two exams on 17th and 18th had made me postpone the update. I have modified the base install to make it more convenient and productive for me:

I deleted the lower panel and moved the window changer to the top panel since my display is a measly 15.6 inches at 1366×768 pixels. My laptop too has the same resolution, albeit at 14.1 inches. Then I added the System Monitor applet and power button to the panel since I need to keep a tab on my bandwidth.

As Rahul Sundaram suggested on Fedora Forums, I’ve switched over to OpenJDK, and all my Java code (there’s not much code actually) runs smooth without any issue. In fact the Java Mail API and MySQL connector run better than the stock Sun JDK which had a few issues. I’d been a NetBeans user for long, but the Eclipse bundled in Fedora 12 is better than NetBeans and it didn’t take much for me to switch allegiance.

Meanwhile KDE has got better compared to previous iterations, but is still short of the KDE Gold Standard set by openSUSE. While on openSUSE, I have a serious issue: No DHT support in openSUSE 11.2. This might be a fallout of the court rulings on The Pirate Bay, so let’s hark back to Fedora.

Empathy is still nascent with no IRC support (really bad, IM – IRC != IM for me) But for the ability to call friends on Google Talk (Yay!) and better integration with GNOME, I’d not have used it much. I use xchat for IRC anyway, but this is something that Empathy should be having.

Last week, my younger brother got some CD for his board exams, which had a few xls files and a massive mdb file. I was scratching my head, and then headed to sf.net. I installed mdbtools and the gui that goes with it, and then imported the tables to a csv file. I used Python to extract the data into a text document, and converted the CSV file to SQL so that I can create an app emulating the windows one using MySQL and Python. That is an example of the power of open source. I often rant about the need for open formats and  ban proprietary formats. Some are plain evil, like Sony’s vem format that you cannot read unless you have the ‘MicroVault’ flash drive.

I’ve installed Qt 4.6 on my desktop, and it is really a ‘cutie’ for developing cross platform apps. Qt + Python = cross platform heaven. I’m going to move over to Qt now on, to get some experience developing using SDK.

Overall, Fedora 12 is just about the best desktop distribution for folks with prior Linux experience, but people who are new to computers can jump onto the bandwagon right away.

Follow

Get every new post delivered to your Inbox.

Join 188 other followers