What is the sound of one hand coding?

Apr 4, 2014 • Dav Clark


Python Koans

This Friday, I propose an exploration of “Koans” for learning python (and potentially other programming languages / frameworks). It turns out there’s a whole internet subculture dedicated to this “test-driven learning” idea that I’ve been talking about with some of you!

As per usual, the Hitchiker’s Guide to Python already knew about this.

Thanks to @ivanov for finding this, and yes, the Koan idea was started by a Rubyist…

The python guide suggests the following links to find more koans on GitHub and on BitBucket.

UPDATE: How’d it go?

The Python koans were surprisingly in line with the official python docs, starting with section 3. The Koans really aren’t usable for a beginner without some orientation to these or similar docs (as is recommended by the above-mentioned Hitchhiker’s Guide.

The Koans are quite dry, and for a beginning non-programmer, they may wonder why they spend all that time on the minutiae of string syntax. Jess did some work making a strings notebook that has the user go through and test whether various python strings are the same or different (using different syntax to get similar or identical strings). For example, are the following equivalent?

str1 = "This has two lines?\n"
str2 = r"This has two lines?\n"
str3 = """This has two lines?
"""

If you’re unsure, your python interpreter knows! And the above link to section 3 in the tutorial should get you sorted out…

Also, it turns out that Behavior Driven Development (BDD) as implemented by RSpec and “such” in nose2 make Jess and Mike cringe. How about you?