• About

    Swaroop C H is 29 years of age. He is a coder and startupper. He has previously worked at Yahoo!, Adobe, his own startup and Infibeam.


    Read more about him


    Email: swaroop (at) swaroopch.com

  • Subscription

    If you want to know when new stories and articles appear on this website, you can receive them via:

  • I'm a Wannabe Hacker

    The Glider: A Universal Hacker Emblem

Archive for the ‘Python’ Category

Text tables

Monday, December 19th, 2005

I was bored with a work-related issue, so veered off to do something fun. I ended up porting Sebastian Riedel’s Text::SimpleTable to Python. Here’s the result.

The module is in the CheeseShop list, for those of you who want to EasyInstall it.

Watching a person learn a skill

Wednesday, December 14th, 2005

I love the moment when you help somebody learn something and they have that sparkle in their eye when they realized they understood it. Here’s one of those virtual sparkles:

Oct 27, 2005:

Decided to abandon “Dive into Python” for the time being, it is REALLY frustrating for me to hanging at chapter 5 without moving forward for so long…. I think it is me, my limitation to understand. So, I decided to surf around the net to look for another tutorial, perhaps a gentler one. Foudn “byte of Python”, 110 pages in all, not too long. So, will give it a go. Hopefully within few weeks, this could equip myself better to go for “Dive into Python” again.

Nov 20, 2005:

Learning Python, still. So far so good, I am on page 85!!! So, that is only 20+ pages to finish it. I consider it a big achievement, hahaha. And, what pleased myself most is that, I finally get through object-oriented programming, hmmm, feel like celebrating already :-)

Nov 25, 2005:

Finished Byte of a Python tutorial, finally. I think the tutorial is good, especially for begineer. But I also think that it is too surface/brief if one really want to take a step further. So the tutorial itself did point out what to do next, where to go for further learning resources.

Dec 2, 2005:

I considered the basic of my contact completed. Now I have function to list out all contacts, add new contacts, delete contacts, and find a contact.

Nothing to shout about really, but the building up of this apps is quite interesting. I just create the barebone of the program to do the basic stuff, then add some validation, or extra functions, like before adding a contact, check if it already exist, if yes, ask whether the user actually want to replace the current one… etc.

Hey, I really enjoy the process. Now I am thinking of the next step, either create a better user interface with some GUI tool, or make it a web application thing. I don’t know if that is over ambitious since this is just the first actual program I wrote in Python, but we will see…

That last part about the contacts program is a task I have suggested to write a program for to test whether the reader has learnt enough about Python.

Django SQLite3 patch

Thursday, December 1st, 2005

A patch I had submitted to Django for the SQLite3 backend, 3 months ago, finally made it through (suitably modified by Adrian). It was a nice surprise to see my name in the list of contributors :-)

foss.in day 2

Wednesday, November 30th, 2005

Today morning, the first session was a Linux Kernel roadmap by Jonathan Corbet. Although I’ve never been a kernel-level guy, the talk was interesting and he clearly explained how features have been added and improved over the various versions, and how the development process has improved and become more “professional.”

![68649354][Thumbnail][]

Then, it was my turn to talk and I talked about TurboGears. The talk went pretty good and it was well-attended which made me quite happy even though I had some tough competition, heh.

![68650388][Thumbnail][] ![68650389][Thumbnail][] ![68650393][Thumbnail][]

I did make two mistakes. First was that I got worried about the time I had to finish the talk, and second, I concentrated too much on the slides. Whenever I have presented well (which has been most of the time, thankfully), I tend to leave slides as guidance for the audience, and have my thoughts free-flowing enough to be coherent and entertaining. Well, I don’t think I’ll be making these mistakes again. However, I did get good feedback about the talk from various people, and a good number of questions after the talk, which is always a good sign. For those who couldn’t attend, my TurboGears slides are online.

And one more thing … my book’s website byteofpython.info is now running on TurboGears! This is only the second public website ever running TurboGears after diggdot.us.

Then, I attended Gopal_V‘s talk on programming in the Mozilla platform. He gave a very detailed approach to creating Mozilla applications and how to go about things. I must get the slides from him later, but it shouldn’t be a problem grabbing hold of him since he works in the same floor as me at Y! His slides are online.

![68650390][Thumbnail][]

I was on my way to the OpenLaszlo talk, but took a peak in the Ruby on Rails tutorial. Does Ruby on Rails really need the CREATE TABLE SQL statements to be written by hand? …. I think I prefer the SQLObject approach of having all the database-schema in one place as simple Python classes instead of having separate database creation and database manipulation (ActiveRecord) parts.. Update: The new RoR migrations feature is simply brilliant. Thanks to Mark Ramm for the tip.

Other than that, Rails looked cool. The directory structure created by rails as well as the test-driven nature was good.

Then, I got into the OpenLaszlo talk by Nirav Mehta. I had seen the OpenLaszlo demos before and used to follow Oliver Steele’s blog, but I never got around to writing anything with it. Nirav kept the audience engaged and showed off some eye candy stuff that OpenLaszlo provides from images to animation. Somebody in the audience asked him to put audio as well, but unfortunately, he didn’t have any mp3s.

Then, my friends and myself headed to the food court and then went around the FOSS Expo section. The Sun Microsystems booth was the best one and they showcased real open source projects such as Belenix (the OpenSolaris LiveCD) and NetBeans. I got a demo of OpenSolaris’ DTrace functionality and it was pretty impressive.

![68652938][Thumbnail][]

Sadly, the other stalls like the Google and Yahoo! booths didn’t showcase any open source projects at all! When Google has open sourced many projects and Yahoo! has contributed open source stuff such as the Alternative PHP Cache, why can’t they show it off and demonstrate they too are part of the community (and invite people to join the company), which I thought was the point behind the stalls…

![68651813][Thumbnail][]

Then, I saw Pramode in the Phoenix stall and it seems people are showing interest in Phoenix which was good to hear. Nearby, Anush and Tejas were in the Python stall and trying to entice people to talk about Python, heh.

Soon, we were back in the Intel hall for Jaya Kumar’s talk on GPL and non-GPL code interaction in the Linux kernel. He stressed that binary-only kernel driver modules are not a good idea and his explanation was pretty simple – it screws users on other architectures and users using different distro-compiler-etc. combinations. Another point is that they are not respecting the people who wrote the Linux kernel. He quoted Linus Torvalds saying it has to be a two-way street, if somebody wants to write something using the Linux kernel, they have to contribute back as well. Jaya Kumar was over-shooting his time slot but he had a lot of interesting examples and incidents to talk about. I think he had more than 100 (sic) slides in his presentation. Outside the hall, Jaya Kumar and Harald Welte were mobbed and they had a good time interacting with others.

![68652936][Thumbnail][] ![68652937][Thumbnail][]

Then, I attended the “FOSS in Education” BoF. Philip, Manish and Praveen were also there. The discussion involved quite a number of issues and Praveen has added a nice page in the FCI wiki regarding the discussion. The focus was mainly in creating awareness, and getting students interested, at the high school level. The emphasis shouldn’t be in simply using open source but stressing the points on why open source is good for everybody, and how the community is the core strength.

![68653470][Thumbnail][]

Phew. As you can gather, it was a long day but an exciting, educative and interesting one.

I was looking at planet.foss.in and hoping to look for any insights from the many talks that I missed today (there are 6 tracks running in parallel!), but it seems very few people write such long posts as dumb me!

foss.in day 1

Tuesday, November 29th, 2005

Today’s the first day of foss.in/2005 and I actually managed to wake up early.

When I reached the venue, I saw a looooong queue of people waiting to get into the place. It seems there was a power outage and because of that, they couldn’t do the registrations. But one of the privileges of being a speaker is that you get to bypass these queues and directly walk in, heh.

![68271611][Thumbnail][] ![68271273][Thumbnail][] ![68271313][Thumbnail][] ![68271403][Thumbnail][]

It was a delight meeting Taj again, and I was standing next to Alan Cox although I didn’t speak to him because I had no idea what to say. He has this persona around him similar to Stallman. Maybe it’s because of his long beard. It was good to meet Andrew Cowie and Dr. Tarique saab too.

![68271653][Thumbnail][] ![68271446][Thumbnail][] ![68271497][Thumbnail][]

The talks started one hour late, and first off, Atul kicked off the inauguration by explaining why foss.in is different from other conferences. Some of the points I remember is:

  • Talks are the side-show. Discussions, interactions, exchange of ideas, etc. is the real agenda.
  • There are FOSS villages, etc. where people can go and start talking, discussing, etc.
  • If 1000 people attend, and 10 people are convinced and jump in to open source and actually contribute, it’s a success. If it’s 50 people, it’s a mind-boggling success.
  • We have no chief guests. The audience is the chief guest. So we have representatives from various Linux Users’ Group to do the Indian tradition of lighting the lamp to inaugurate the start of the conference.
  • The motto of the conference is the poem ["Where The Mind

Update : First, WP was cutting off comments, and now it's cutting off posts too!? Anyway, I'm adding some of the points of the first day I still remember but it's been 3 days already... :

![68271570][Thumbnail][] ![68271810][Thumbnail][] ![68271847][Thumbnail][] ![68275699][Thumbnail][]

The first keynote speech was “Use the source, luke” by Alan Cox. Surprisingly, for a hardcore technical person like Alan Cox, he spoke very well and catered to a non-technical audience as well. He illustrated many points very well, such as learning by doing as the only practical way and stressing that reusing code should be done and is strongly encouraged. Also, he explained how bug reporting is a simple aspect of getting non-programmers involved in the community as well.

![68278613][Thumbnail][]

Danese Cooper’s talk on FOSS : Opportunities for India was very good. She stressed on various things, including teaching your daughters to code.

![68278678][Thumbnail][]

Due to the delays in the morning, the talks were running in different orders in different halls, and I missed Rasmus’ talk on XSS in the confusion.

Then, I attended Pradeep’s talk on educational content sites using Plone.

![68278827][Thumbnail][]

Gopal’s talk on DotGNU was interesting, and he explained how he became the de-facto guy because of which DotGNU was moving forward since the main developer was no longer interested and turned his attention to building model ships. Though, I had heard this talk before when we were in Kerala last month.

Next, we attended Cowie’s talk on equivalence which is a nice word play. Equivalence is useful to build java-gnome and getting it running. He explained why the current tools suck and why he needed something to simplify the entire process.

![68271760][Thumbnail][]

Finally, I caught the latter part of Atul’s talk on Impact of FOSS on Everything.

PESIT FOSS Day

Tuesday, November 29th, 2005

Last Thursday (24th November, 2005), there was a FOSS Day at PESIT, my alma mater.

Typically, I managed to leave office and reach PESIT at 4.10 when I was supposed to be there at 4. The venue had shifted from the hall in the “new” building to the MCA seminar hall, because of confusion on who had booked the original hall or rather who gets to use it.

When I entered the MCA hall, there were quite less number of students, but they slowly started trickling in and finally filled up the place. I met one of my teachers (after 2 years) and he still remembers me by name. That was cool.

The first talk was by Tejas on ‘Why FOSS?’ where he gave the “free as in freedom, not free as in beer” speech. I don’t think there has ever been a FOSS introductory talk without that phrase. Then, he dispelled some FUD on FOSS. Yes, open source software does not necessarily mean free software but the vice versa is true.

Next was Anush talking on FOSS development.

![67103133][Thumbnail][] ![67103478][Thumbnail][]

Then, it was my turn to give my usual ‘Slither Away with Python’ talk. This must be my fifth or sixth Python intro talk that I have given :-) .

I was worried that my coughing would affect the talk, but Vicks VapoRub came to the rescue. Man, that stuff is powerful. Anyway, I digress…

It’s fun to introduce a language like python to students who know only C/C++. The first thing that amazes them is that you can type at the interpreter prompt and gives back results immediately, no edit-compile-run cycles. One of the evergreen examples is the swapping. I asked them on the algorithm we learn on how to swap variables in C and they promptly gave me the function that uses pointers to achieve the same and I said ‘This is how you do it in Python’ and typed b, a = a, b. Of course, you can do that in almost any modern interpreted language these days, but they didn’t know that, heh. One of the cool things that is specific in python is the slicing such as a[:4] to get the first 4 characters of a string and the for..in loop, which the audience was impressed with.

![67103354][Thumbnail][]

Shreyas was next. He was my classmate, I was meeting after a long time. He was supposed to speak on debugging. Although, he had a 17″ PowerBook with him (with a “Suse Linux inside” logo, although he was still using Mac OS X :-P ), he didn’t have any source code to demonstrate the talk and there was no connectivity at college.

![67103695][Thumbnail][]

He did talk about the importance of real world skills and how learning to read code is one of the most important skills that a programmer needs to learn. He gave some examples from his own experience. One of the examples was how he was working on some OpenOffice bug along with Michael Meeks and Miguel de Icaza. He started working on the problem while these guys went out for a break and when they returned, they solved the problem in a jiffy. He asked “How did you guys solve this so fast?” assuming he was pretty smart compared to them (no comments there from me). They said “I had seen the code before.” There you go. Simple and straightforward answer, but a lot to understand from that. The students were quite inspired by his talk.

![67103794][Thumbnail][]

This was followed by Praveen speaking on the education software initiative.

Atul was late for his slot. Unfortunately, quite a few students left during this gap. Well, it was their loss, because Atul’s talk was thought-provoking and he really made the students feel that they can do something innovative and they can do it now. He gave many examples of students such as Kalyan, Shreyas and even me (okay, I admit it, I was surprised to be part of that list).

![67102997][Thumbnail][]

Two of his slides said “There are two times you can innovate. One is when you are a student. The other is when you retire.” …. I hope that’s not an absolute statement, because that means there’s no hope left for me! However, it is true that I have not been able to do so many things that I wanted to do, compared to my college days when I had done a lot more.

![67118897][Thumbnail][] ![67118988][Thumbnail][]

Overall, the day was successful and it seems quite a number of students have got enthu to do stuff now.

Note: Tejas and Praveen have entries regarding the day on their blogs.

It’s a small utility

Wednesday, November 23rd, 2005

When Atul commented about open source being “seen as some kind of ‘hobbyist’ thing” in India, I was reminded of another incident in college.

In 6th semester of VTU B.E., we had a DBMS (Database Management Systems) lab. We were supposed to write some software that demonstrates database design, ‘understanding’ of SQL and using databases in a programming language.

As per the norm, 98% of the class used pirated copies of Oracle and Visual Basic, but Yashwanth and myself had a policy of doing “doing interesting things” and the Oracle-VB projects had been done to death especially with the same topics appearing every year. We were big open source fans by then as well. Moreover, we had a policy of not programming on Windows*. There was only one project we were forced to work on Windows in the entire B.E. and we flicked that one. I think it was Graphics lab where we had to create a paint program using Turbo-C on DOS… later, I found out that there were alternatives such as the Allegro library that Amit Gandhi Manu Bhardwaj used.

Coming back to DBMS lab, we were seeking to do a “real world” project, and finally came up with creating a medical laboratory management software for an uncle who was a doctor. He planned to use the software to manage the diagnostic laboratory where he is a partner. So, we two got all excited about it, and uncle wanted us to do the software on Linux. I would’ve never imagined a doctor asking for a software to be developed on Linux. We immediately got started and worked on the “analysis” and database design during the one month of holidays we had before the actual semester started. I called it “Diamond” which stood for DIAgnostic Medical centre OrgaNizing Device (or something like that).

The choice of database was MySQL since it was easy to get started with, at that time. We were discussing which GUI toolkit to use and we had to choose between Qt and GTK. I wanted to use GTK but Yashwanth wanted Qt. He said, in very strict terms, “We are going to use Qt only” and finally I caved in. In hindsight, that was a good decision. Soon, we went through all the tutorials and learnt to use the Qt Designer (that thing totally rocks).

A few weeks after the semester started, we had to register our project details, and our teacher came up with an objection for us. He told us not to use MySQL. We asked “Why?”. He said “MySQL is a small utility in Linux to store data. You should use a database system like Oracle for your projects.” It took us several moments to recover and then I started arguing that there are many companies using MySQL and besides this software will be actually used by someone instead of being thrown away like every other project, and so on. He still didn’t accept it. We finally went to the Asst. HOD and fought with him. He finally relented after he realized that we were not going to change our minds. It helped that I had a good rapport with him.

So, after the roadblocks were cleared, we worked on the project and we had an awesome time learning MySQL and Qt while working on the project. The demo in our lab exam went smoothly and our (internal) invigilator was very impressed. It was unfortunate that the software itself was never used by my uncle due to reasons that are beyond me. However, I was glad that I did the project because I learnt a lot.

Readers of my book will recognize that the next part of the story is where I learnt Python.

If only I could tell that teacher about the kind of things for which we use MySQL at Y! ….




* I don’t hate Windows nor people who use them. It’s simply a matter of personal choice and preference. I prefer Linux and Mac OS X.

Memories of Linux Bangalore 2003

Sunday, November 20th, 2005

The VTU letter exhorting principals to motivate students to attend foss.in is a far cry from my college days, and perhaps even farther from Kalyan’s days.

I remember asking our department’s Assistant HOD (I don’t remember his exact designation) whether our semester laboratory internals tests could be postponed so that we can attend the 2003 Linux Bangalore… he rubbished me and shooed me away from his office.

My partner Yashwanth and myself still wanted to attend Linux Bangalore at any cost. So, on the first day, we reached our college lab early and requested our ma’am to take a look at our project early so that we can attend Linux Bangalore. It was our fortune that ShriVidya ma’am (she had contributed to GCC in the early 90′s, wow!) agreed and sent us off even before the previous batch students’ projects were looked at. We then got on our bikes, raced off towards IISc and had a terrific time. The Miguel-and-Nat show was the highlights of course, and I enjoyed every moment.

Later that day, we had to again rush back home and actually do our Perl/CGI project to show the next day. We had never worked on the project in the whole semester because I had already created our (erstwhile) LinCDs.com where we used to sell CDs with Linux for reasonable costs. We submitted the same as our project and it was already running live. So, we had to make some changes to make it more VTU-compatible and we were done in just a few hours.

The next day, Yashwanth was hanging out at the Yahoo! booth and I was hanging behind Miguel and Nat. Eventually, he got into Yahoo! interviews and finally joined as an intern. During his interviews, he mentioned our LinCDs.com and the interviewers were (sort of) impressed with the website and after finding out that I had written it (I used my own XML schemas and used the XML::XSLT CPAN Perl module to render the site….) and asked me to send my resume. So, I thought, sure, why not. Then, I got into the programming tests. After that, there was the programming round where I was asked to write a shell. I was happy that they gave me a problem which I actually had some clue about.

I was asked to implement program execution, tab completion and a history, and was given any choice of language (the platform had to be FreeBSD though), and about 3-4 hours of time. So, I chose Python and although they were surprised, they asked me to go ahead. I struggled for nearly 2 hours trying to get character-by-character input working! I just didn’t know how. I finally asked Kalyan (who was sitting in the same cubicle as me) whether I could use the internet and he said of course. Duh! Then, in two seconds Google (yes, Google) led me to a Python Cookbook recipe which solved the problem for me. After that, it was a piece of cake to use the os.spawn method to run the commands, used os.listdir to get the directory contents for tab completion, and finally just used a list to maintain history. I was so relieved that I actually got it working.

When a different set of interviewers came to ask me about the implementation, they were surprised to know that I wrote the program in Python and even wrote a “book” on it. A funny moment was when they asked how much history I was maintaining, and I said unlimited, because the Python list can store as much as the computer’s memory allows, and they didn’t quite expect that, mostly because they were used to #define SIZE 100 in C++ programs written by other students.

So, that’s the story of how I got into Yahoo! It’s interesting how it all started with Yashwanth and myself playing around with Red Hat 7 Linux and getting interested in open source…

Why did I recollect all this today? Well, foss.in, the newly-renamed Linux Bangalore conference is just 9 days away. So, go ahead and register yourself (if you haven’t already).

Update:

Thrissur again

Monday, October 31st, 2005

I was invited back to Thrissur to present a talk to engineering students. Since I didn’t want to give the same ol’ introductory Python talk at the same place, I decided to talk about TurboGears, since that’s been pretty much the only new thing I’ve had time to explore off late.

Talkin' TurboGears

I left in a train on Thursday afternoon, reached Thrissur on Friday morning, left again on Friday evening, and back in Bangalore on Saturday morning, and I had so much fun in-between all that.

I have a lot to write about this event and the various talks and demonstrations that were happening. However, Pramode has such a good writeup about Insignia ’05 that I didn’t feel the need to write about it myself.

Also, I don’t have any pictures from this event since I forgot my digicam when I was hurriedly packing to reach the railway station on time.

Note: I will be speaking on TurboGears at foss.in/2005.

Willison has entered the building

Thursday, September 22nd, 2005

Simon Willison has joined Yahoo! This is exciting.

For those who don’t know Willison, it’s sufficient to say that every web developer in this world should be forced to read Willison’s blog to become better designers. To jog your memory even more, he is one of the guys who created Django.