Thank you Mo Lun for creating a brand new Chinese translation of the latest version of A Byte of Python book!

In Mo Lun’s words:

I am a common journalism student from CYU, Beijing. And actually, I am an absolute newbie in Python programming when I start to translate this book. Initially, it was just a whim, but when I done this work, I realized that a decision triggered by interest had prompted me to go so far. With the help of my predecessors’ translations and the vast amount of information provided by the developed Internet, and with the help of my friends, I prudently presented this translation edition. I just hope my translation work will help other newcomers in learning Python. At the same time, I am always waiting for my translation of the comments and suggestions, and ready to change or improve this superficial work.

Note that the full translations list is at and you can read how to create a new translation at

I have converted the book to AsciiDoc format and also converted the book back to Python 2 (I got tired of readers emails who were confused between using Python 2 and reading the Python 3 version of the book and vice-versa).

Please let me know any feedback regarding the same.

We have “database APIs” such as abstraction layers over multiple SQL databases and ORMs. But why not take it to the next step and make it a REST API like any other network call that we can make?

Database as a REST API
Database as a REST API

Advantages would be:

Did we just sort-of reinvent Datomic?

Of course, this is not a new idea at all, take restSQL as an example – my question is why is this not talked about more often?

Do most frameworks support this? If not, why not? If so, why don’t most frameworks don’t talk about such a use case in their documentation? If I use Django, I’ll start writing the models and use South to create migrations, and that’s that. If I have to reuse those model, from say, Java, then you’re on your own. The point is that, by default, Django (or Rails) doesn’t encourage you to do such a thing. If you go for a lighter framework such as Flask, then this becomes easier because the ORM is anyway not part of the framework.

Is this concept felt needed only in a polyglot case (multiple database systems, multiple programming languages)?

P.S. Also read Stevey’s Google Platforms rant.

Update on [2013-04-28 Sun]: Also see the very useful tech talk Designing a Beautiful REST+JSON API.

I was reading about the EDN format over the weekend. EDN (pronounced like in “eden garden”) is a data format in the same league as JSON but is supposed to have some nifty features such as sets, keywords, date-time type, custom types, and also being a proper subset of Clojure.

Having a date-time type as well as custom types seems useful to me, so I was taking a look at the current Python implementations of the EDN format and I didn’t find them satisfactory, for example, one of the listed ones had all custom parsing code which was difficult to read, one was not even a real implementation, just boilerplate code, etc.

So I thought why not create a better implementation and I did – it is up on GitHub at

It has been a long time since I did lex and yacc, so it was a fun weekend project :)

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 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.

55 people have asked me to write about:

Indian companies just don’t take Python seriously, not as much as Perl. Why is that?

28 people have asked me to write about:

Most companies opting for Ruby as their programming language of choice instead of Python

51 people have asked me to write about:

The future of the Perl programming language?

Phew, that is quite a lot of people asking about programming language adoption!

The TLDR version of my thoughts on this topic is: Companies are choosing the right tool and the right community for the right job. Which programming language is used in your company depends on the kind of work they are doing.

Ruby and Rails ecosystems are built by and built for web programmers. That is why you will see web programmers switching from PHP and Python to Rails. For web programming, I do believe that Rails has an edge, not just because of the framework itself, but because of the community rallying around it. The amount of amazingly useful stuff that they churn out outpaces any other community w.r.t. web-dev, and they even have quick effective screencasts to make it digestable, hence their edge!

Data analysis is the hot thing these days and as per O’Reilly, Python is the choice of language for data analysis even though Ruby gets more buzz in the tech news. It is the same reason why scientists are switching away from Ruby to Python.

Similarly, I believe that Perl is still used a lot as a “glue language” and “text munging language” which has always been its forte and continues to be its forte, although Python and Ruby have been slowly entering that territory. Even though there are marketing reasons why Perl is no longer as popular, if you do use Modern Perl, you can be as effective as with the other two languages [1]. For example, if you notice the recent announcement of Amazon “Simple Email Service”, you will notice that their scripts SDK is written in Perl! Also, if you read the latest Perl news it is not lagging behind the other languages, it just doesn’t get the “buzz” factor these days. Programming languages are like fashion, they keep coming back in cycles. Remember the days when JavaScript was considered a pain and today, it’s the new hotness? (same goes for Haskell) We owe a lot to Perl and perhaps Perl 6 will teach us the future of things yet again, who knows!

So I have a question back for the 134 people who asked the above 3 questions – Is the programming language chosen by your company match the kind of community we have described here?

What would you say to these 134 people?

[1] Perl was the original magical language which I still have a soft corner for, since I have written a lot of Perl code at Yahoo! and thoroughly enjoyed it.

“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).


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 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.