• About

    Swaroop C H is 27 years of age. He graduated in B.E. (Computer Science) from PESIT, Bangalore, India. He has previously worked at Yahoo! and Adobe.


    Email: swaroop (at) swaroopch.com

    Read more about him

  • Subscription

    If you want to know when new stories and articles appear on this website, you can subscribe to the RSS feed or have them emailed to you.

  • Want me to write about something?

  • I'm a Wannabe Hacker

    The Glider: A Universal Hacker Emblem

Archive for the ‘A Byte of Python’ Category

Coding Problems for Homework

Tuesday, November 24th, 2009

“Coding Homework” is a small website that I have built to list small problems that one can work on, to learn how to use a new programming language. For example, small problems requiring to read from a file, or to use regular expressions, how to find duplicate files in a folder, and so on.

Note that the problems listed on the site is not for testing your algorithm skills, there are many sites for that already.

This list was inspired by repeated requests and suggestions from readers of A Byte of Python for homework problems at the end of each chapter to exercise the skills they have just learned. So I thought why not make it applicable to any language and multiple programming skill levels. And it’s a good topic that can be collaboratively worked on with the programming community, à la Stack Overflow.

All the content will be licensed under Creative Commons Attribution-Share Alike 2.5 India License so that anybody can reuse this content, especially in classroom situations.

Screenshot of "Coding Problems for Homework" website

I also had my own specific goals when implementing this side project:

  1. Solve the lack of “homework problems” for people to exercise their programming skills, especially in the context of learning a new programming language.
    • I am not trying to replace existing lists but rather focus on making the reader active (providing exercise problems) than letting him/her be passive (reading code listings).
  2. Learn how to do website layouts, specifically how to use YUI Grids CSS.
  3. Learn how to pick colors for website design; ColorCombos turned out to be useful.
  4. Learn to use Google App Engine.

It has been a fun side-project, spending a few hours here and there. It is very far from polished, but the basic functionality works. There is still more to do — adding a search functionality, conforming to standard UI design patterns, caching for the rendered HTML (from Markdown), optimizing the housekeeping code, and so on.

This site itself is a good example on the kind of problems that beginners can work on, but they would not know what kind of problems they can solve and what level of expertise (beginner / intermediate / advanced) would be needed. That is where this list of problems can help.

I request you to spend 5 minutes of your creativity to add a few problems so that beginners and intermediate level folks will have interesting problems to test their learning of a new programming language. Thanks!

It might be helpful to you as well when you’re going to play around with functional languages (Haskell, Erlang, etc.), funky new languages (Ioke), or new languages by big companies (Go).

Link: http://codinghomework.appspot.com

An interactive version of A Byte of Python

Monday, November 9th, 2009

Roorky is a new startup that has created a new file format and software for interactive books. As part of the default installation of the software, they are bundling A Byte of Python free with the software.

What is interesting is that this may help complete beginners who stumble in getting started with IDLE, etc. The most common email that I get asked is when people run python abc.py on the IDLE interpreter prompt and wonder why it is not working – both the concepts of two command lines as well as the concept of running a program is not grokked well by beginners who are getting started, especially people who are self-taught. From that perspective, this is an interesting approach to the problem.

I am still not convinced about this approach because people cannot bypass the learning of how to edit, compile and run the code in the native environment, because that will be needed when writing new programs. It will be interesting how the two opposing needs will be balanced.

But I hope beginners will try it out and see if it helps them get started.

A full size video of a walkthrough of the software is available at the Roorky website.

Note: Be warned that it is a beta software.

Interview with CocoaCast

Thursday, May 7th, 2009

I was recently interviewed by CocoaCast (mp3) to talk about Python for their Mac developer community, as part of their “Unbound Developers” podcast series.

I was apprehensive about doing this because I’ve never been live-interviewed before, but in the spirit of doing new things, I went ahead and it turned out to be fun.

We talked about Python, my background and my startup, Macs, Python vs. Ruby and Django vs. Rails, Apple and Google, cloud computing, databases, Scala/JVM, performance, collection classes, and so on.

Surprisingly, Vlad and myself had talked for nearly 25 min. It’s a fun interview, although, there’s probably nothing new to know from this podcast for those who have already read the book.

A Byte of Python in hard copy

Wednesday, October 1st, 2008

If you’re the kind of person who prefers to read a physical book vs. online books, then you’ll be happy to know that the A Byte of Python book is now available as a printed hard copy.

The best part is that the hard-working translators can also publish their translations and sell the printed copies, benefiting both the readers and the translators.

I had received many requests from readers for hard copies of the book and I’m glad to finally get this working. Interestingly, I was previously trying to get the book printed via CreateSpace because the book would automatically get listed on Amazon.com (since CreateSpace is owned by Amazon). However, their process was not streamlined and confusing. Worse, I couldn’t get the PDF in their required size formats because of a bug with mwlib.rl.

I got tired and decided to try Lulu and I was very surprised. They are miles ahead in terms of usability of their service as well as wide range of options and sensible defaults. For example, it was a pain waiting for manual approval of the book by the CreateSpace staff and it is an unnecessary delay every time I upload a new version. On the other hand, Lulu made it very easy to design a rudimentary cover using their process. Overall, I was able to make the printed copy available for purchase in a single evening.

Of course, all this is possible because of the ability to generate PDFs from a wiki, thanks to the nice people at PediaPress.

Update: For Indian readers, the book is now available via pothi.com.

Book updated for Python 3.0

Friday, September 5th, 2008

After a gap of 3.5 years, I’ve finally updated the ‘A Byte of Python’ book.

The interesting news is that it is updated for the upcoming Python 3.0 language making it probably the first book to be released for Python 3.0.

The book is now a wiki too at www.swaroopch.com/notes/Python which means you can contribute too!

The book and wiki are now under the Creative Commons Attribution-Share Alike 3.0 Unported license. The Non-Commercial clause present in the previous edition of the book has been removed. It was becoming a hurdle for translators as well as people who wanted to use the book for genuinely good activities, so I decided it to drop the clause.

Since it is a wiki, volunteers can directly create their translations on the wiki. This eliminates the need to learn DocBook XML and its tools which had become a hindrance for many translators, and I’m glad to see this already bearing fruit with Eirik Vågeskar starting off a Norwegian translation at www.swaroopch.com/notes/Python_nb-no:Forord.

I will soon be making a printed version of the book available as I have had many requests for this.

So back to the main question: Why an update after nearly 4 years? Two reasons.

First, because of foss.in. I dedicate this new release to the foss.in community for their spirit and enthusiasm over the years which have rubbed off on me and kept me working on the update of the book.

Second, Over the past few years, the readers’ reactions have been simply splendid:

Neil (bigdealneil-at-yahoo-dot-com) said:

“(I) got an if else to work and I can follow your tutorial, which I have never been able to do no matter who wrote the thing! you’re a genius Swaroop!”

Gao shuai (ejwjvh-at-126-dot-com) took the effort taken to write an email to me in English:

dear swaroop: I am a chinese student.My name is gao shuai,”gao”is my family name. Although your book is easy to understand,but my english is bad,so what I read is the chinese edition. I have made some programs now.It is interesting.I like it very much.

I emailed back and he replied:

Mr Swaroop: I am exciting to read your back. _(Editor’s note: I think he means ‘reply’)_ Tt is the first time that I talk to foreigner though the internet. I saw that you have your own mail ab.I think You’re a great man. Thanks for your back!(*^_^*) regards, gaoshuai

The interesting part is that this student somewhere in China was being benefited by this book and he “talked to a foreigner through the internet for the first time” and that person was me. It was truly humbling.

People are even putting ads for it, and I had no clue about it until I chanced upon it myself:

An ad for 'Byte of Python'!

If that wasn’t enough, I found out that there are 8-9 university courses officially using the book, including Harvard and other institutions. And apparently even NASA is using the book in their Jet Propulsion Laboratory.

Users have suggested that it should replace the official tutorial but I really wouldn’t go as far as that :)

Recently, I had sent a sneak peek for the book’s group of readers and within a day, I had the first 10$ donation by Horst JENS. I remembered seeing that name somewhere, so I searched my emails and found this:

On Mar 4, 2007:

“Hello Swaroop, i teach a class of (3) Children how to program in Python. Just want to thank you because without your ‘a byte of python’ (that i read one year ago) i would maybe never have begun to code in python and consequently would never leaved my old job to become a Python teacher.”

A person in Vienna, Austria changed his career from a sys-admin job which he didn’t like, to teaching children about programming, a job he loves. Wow! Again, this is so humbling. I could have never imagined that a small book can make such a difference.

The point is that I’m grateful for all these people writing to me and sharing their delight and stories. The book is still alive and kicking thanks to all these people.

Happy programming!

Brazilian Portuguese Bytes of Python

Wednesday, June 14th, 2006

Samuel Dias Neto has translated “A Byte of Python” to Brazilian Portuguese.

Hats off to Sam!

German Bytes of Python

Monday, March 13th, 2006

Yesterday, I got this mail from Christoph Zwerschke:

Thanks a lot for “A Byte of Python”. Since I thought it would be great if Python gets more popular in German, I participated in the German translation project at BerliOS started by Lutz Horn. Unfortunately, the translation progress stalled last year shortly before the work was finished since all of us were very busy. However, this weekend I found some time to finish the translation and cut a German release, which is now available at http://abop-german.berlios.de.

Greetings from Germany, Christoph Zwerschke

Hats off to Christoph, Lutz Horn and others who made the German version happen! Thank you guys :-)

Byte of Python is now a wiki

Wednesday, February 22nd, 2006

In a recent discussion on the byte-of-python list, an enthusiastic bunch of people were interested in seeing A Byte of Python available as a wiki so that readers can contribute directly as well.

So, I followed up and made this announcement on the list recently :

Hello all,

As we have discussed, suggestions that Byte of Python should be converted to a wiki garnered enthusiastic responses. I’ve finished converting the book to the wiki and is available at http://swaroopch.info/text/Byte_of_Python:Main_Page .

There are some Todos I’ve sprinkled across the book which I will be working on in the coming weeks. Few readers have taken the trouble in pointing out how to export a book from the wiki as well. Once I can work on the todos, I’ll work on a downloadable version.

A good advantage of the wiki is that my turn-around time to suggestions from readers have improved. For example, a user pointed out that ESR is not the one who coined the term ‘open source’ and I corrected it on the wikibook within 2 minutes.

If you want to add/remove/improve any text in the book, please feel free to register as a user on the wiki and start editing. However, if you only want to read the book, there is no need to register.

Help about how to use the MediaWiki is available at http://meta.wikimedia.org/wiki/Help:Contents .

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.

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!