When my wife was editing my books, she used Mou.app for live preview of the text so that she knows what the output is going to be like. The caveat was that Mou.app does plain Markdown and not Pandoc format which would mean the preview would be screwed up whenever there was a code block, etc., so, today morning, I hacked up an app called “Kalam” which does exactly that – live preview for Pandoc text.

The app is based on top of node-webkit (which I came across when I was wondering what Light Table is built upon), created by Roger Wang and others at Intel China Open Source centre, they’ve basically integrated node.js into webkit and disabled all the security restrictions, which makes it the almost-perfect cross-platform desktop toolkit – write HTML, CSS, JavaScript and use any node.js module!

Update: There’s also AppJS which is the same concept as node-webkit but looks more polished (via @aravindavk)

Some people, when confronted with a problem, think “I know, I’ll use a wiki” Now they have no idea how many problems are there.

Andrew Clay Shafer

The above quote summarizes my experience in the past years in having converted A Byte of Python book into a wiki. I was hoping to make it much easier for readers to make corrections and contributions to the book. The only thing it enabled is tons of spam.

The second issue was that lots of readers kept emailing me to ask about ebook and kindle versions of the book which I could not do because it was stuck in a wiki format.

The solution was obvious – Pandoc, but it just seemed too daunting a task to do and hence I delayed it for years. It has been done now, thanks to my wife who did the conversion from the earlier Mediawiki syntax.

I also wrote a small Fabric file to update the websites in a single command invocation – so now I can edit the book and by running one command, it will update the book chapters pages on the WordPress site as well as generate and update the PDF and EPUB files stored in AWS S3.

I have also made a few quick changes to the text:

  • Overhauled installation and first steps chapters for Python 3 and explaining how to find and open a terminal application in detail
  • Recommending newbies to start with ActiveState Komodo Edit editor and instructions on how to use it to create and run a source file
  • Removed unnecessary sections such as nonlocal, metaclasses, exec and eval, etc.
  • Moved escape sequences in strings to the ‘More’ chapter in the end, it was an unrequired hurdle

I haven’t done an exhaustive review of the text yet, because frankly, that is draining, but I hope this is the start of me responding to readers’ suggestions on how to improve the book.

Enjoy the new EPUB and PDF formats. The sources are at http://github.com/swaroopch/byte_of_python. Kindle edition, etc. coming soon.

Everyday I get emails from readers of my books that makes me wonder: Am I continuing to make an impact everyday? Can I have the same impact again through my work? Maybe, let’s see.

But still, it’s difficult to top this:

I’m a 16-year-old boy from Guangxi,China.

Thanks for the book named A Byte of Python of yours.I learnt lots of things from it.

And this:

Dear Sir,

I have never been able to program before but with your byte of python I actually managed to not only write the small programs but even understand. For me this is good because I am 57 years old and I always gave up any programming I attempted to learn before no matter how desirable a goal it seemed. The real problem I run into is what the words mean. I consider myself fairly literate but when I run into a special word I do not know the meaning of, it frustrates me, especially when I cannot find a definition, and there goes the understanding. Also, there are gradients of knowledge that are skipped. One minute you’re riding along nicely and the next minute you’re behind the 8 ball. Along the way, one quits. You, on the other hand, seem to have undercut this better than anyone I have encountered before. Your explanations are clear and concise and you define words well so I understood more of python than I have of any other language including Basic which I tried and gave up on years ago and the understanding flows very well. And you’re giving hope to an older person who really wants to learn to program!

Thanks so much

These emails are enormously humbling and reminds me to continue to focus on the impact of what I do.

“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

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.

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.

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.

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!(*^_^*)

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!

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 :-)