Sometimes getting familiar with programming languages is not that easy, even with Python. You read some tutorials, try some examples, maybe even write a few test programs. But if you don’t have a plan on how to attack learning progress - you’re sort of in trouble.

Learning with Koans

A great way of learning a new language and understanding its concepts is by doing so-called Koans.

You get a number of tests (Test Driven Development to the rescue!) and you have to write code that passes those tests. Simple enough? Maybe.

For last four days I’ve gone through Greg Malcolm’s Python Koans. It’s been a lot of fun and I’ve learnt quite a bit about Python. It is also important that you can track and measure your learning progress at all times.

For the most part you just need to fill in the blanks to make tests pass, however on some occasions you need to write implementation code rather than test code.

At the moment of writing there are 291 tests in 36 lessons, but don’t let these numbers scare you, it’s not as hard as you think.

The part that I liked most was learning more about decorators. I learned that not only you can decorate with functions, you can decorate with classes as well. The hardest parts probably were “Accessing attributes” and “Proxy object project” because they involved overriding standard getattr and setattr methods and involved a set of fun things to deal with.

Problems with Koans

Even though doing koans is helpful in understanding concepts and getting a better grasp on syntax and constructions, I don’t think that it will be enough to only do Koans. It is not a silver bullet. Don’t get me wrong, I don’t say that they’re worthless, but as I mentioned, for the most part you’ll be only filling in blanks. Also there’s another problem. You can go through most of it without even thinking, just run the code and an  AssertionError will tell you the right answer. I must admit, that I cheated like that with exception texts as knowing the error is not enough - you need to type error text precisely.

Final thoughts

Regardless of the cons I mentioned above, I really recommend you to look for Koans for a language you’re currently learning and try it yourself. Find your way to enlightment!

Python Koans is a port of Ruby Koans by EdgeCase. You can find similar koans for other languages on Github. Here is a list of a few I found: