Python has never been a language I have had to know well. I’ve adapted existing scripts, I’ve created a few simple scripts from scratch. But I haven’t learnt it properly, just the parts I’ve needed.
I decided it was about time I learnt the language properly. A friend recommended that I take a look at python koans. A koan is a riddle or puzzle use in Zen mediation to help gain enlightenment.
Python Koans is an interactive tutorial for learning the Python programming language by making tests pass. Tests are executed by executing contemplate_koans.py
python contemplate_koans.py
A single test will fail, tell you what has failed, and what you need to think about to make it pass.
Most tests are fixed by filling the missing parts of assert functions. Eg:
self.assertEqual(__, 1+2)
which can be fixed by replacing the __ part with the appropriate code:
self.assertEqual(3, 1+2)
Very quickly I got in a rhythm, much like TDD, red, fix, green, repeat. I would definitely recommend this as a way of learning the language.