You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python Koans is an interactive tutorial for learning the Python programming language by making tests pass.
10
+
Python Koans is an interactive tutorial for learning the Python programming
11
+
language by making tests pass.
10
12
11
13
Most tests are 'fixed' by filling the missing parts of assert functions. Eg:
12
14
@@ -16,9 +18,13 @@ which can be fixed by replacing the __ part with the appropriate code:
16
18
17
19
self.assertEqual(3, 1+2)
18
20
19
-
Occasionally you will encounter some failing tests that are already filled out. In these cases you will need to finish implementing some code to progress. For example, there is an exercise for writing some code that will tell you if a triangle is equilateral, isosceles or scalene.
21
+
Occasionally you will encounter some failing tests that are already filled out.
22
+
In these cases you will need to finish implementing some code to progress. For
23
+
example, there is an exercise for writing some code that will tell you if a
24
+
triangle is equilateral, isosceles or scalene.
20
25
21
-
As well as being a great way to learn some Python, it is also a good way to get a taste of Test Driven Development (TDD).
26
+
As well as being a great way to learn some Python, it is also a good way to get
27
+
a taste of Test Driven Development (TDD).
22
28
23
29
24
30
Downloading Python Koans
@@ -38,26 +44,33 @@ Either site will allow you to download the source as a zip/gz/bz2.
38
44
Installing Python Koans
39
45
-----------------------
40
46
41
-
Aside from downloading or checking out the latest version of Python Koans, you need to install the Python interpreter.
47
+
Aside from downloading or checking out the latest version of Python Koans, you
48
+
need to install the Python interpreter.
42
49
43
50
At this time of writing, there are two versions of the Python Koans:
44
51
45
52
* one for use with Python 2.6 (it also works with Python 2.7)
46
-
* one for Python 3.1.
53
+
* one for Python 3.1.
47
54
48
-
You should be able to work with newer Python versions, but older ones will likely give you problems.
55
+
You should be able to work with newer Python versions, but older ones will
56
+
likely give you problems.
49
57
50
58
You can download Python from here:
51
59
52
60
http://www.python.org/download
53
61
54
-
After installing Python make sure the folder containing the python executable is in the system path. In other words, you need to be able to be able to run Python from a command console. With Python 2 it will be called 'python' or 'python.exe' depending on the operating system. For Python 3 it will either be 'python3' or for windows it will be 'python.exe'.
62
+
After installing Python make sure the folder containing the python executable
63
+
is in the system path. In other words, you need to be able to be able to run
64
+
Python from a command console. With Python 2 it will be called 'python'
65
+
or 'python.exe' depending on the operating system. For Python 3 it will either
66
+
be 'python3' or for windows it will be 'python.exe'.
55
67
56
68
If you have problems, this may help:
57
69
58
70
http://www.python.org/about/gettingstarted
59
71
60
-
Windows users may also want to update the line in the batch file run.bat to set the python path:
72
+
Windows users may also want to update the line in the batch file run.bat to
It also tells me exactly where the problem in, its an assert on line 12 of .\koans\about_asserts.py. This one is easy, just change False to True to make the test pass.
105
+
It also tells me exactly where the problem in, its an assert on line 12
106
+
of .\koans\about_asserts.py. This one is easy, just change False to True to
107
+
make the test pass.
91
108
92
-
Sooner or later you will likely encounter tests where you are not sure what the expected value should be. For example::
109
+
Sooner or later you will likely encounter tests where you are not sure what the
110
+
expected value should be. For example::
93
111
94
112
class Dog:
95
113
pass
@@ -98,7 +116,8 @@ Sooner or later you will likely encounter tests where you are not sure what the
98
116
fido = self.Dog()
99
117
self.assertEqual(__, isinstance(fido, object))
100
118
101
-
This is where the Python Command Line can come in handy. in this case I can fire up the command line, recreate the scenario and run queries:
119
+
This is where the Python Command Line can come in handy. in this case I can
120
+
fire up the command line, recreate the scenario and run queries:
@@ -120,38 +139,39 @@ Quoting the Ruby Koans instructions::
120
139
Content
121
140
-------
122
141
123
-
The Python Koans is a made up of about 2/3 Ruby Koans ported material and 1/3 Python specific tests. The content ported from Ruby Koans includes all the assignment projects.
142
+
The Python Koans is a made up of about 2/3 Ruby Koans ported material and 1/3
143
+
Python specific tests. The content ported from Ruby Koans includes all the
144
+
assignment projects.
124
145
125
-
Content for Python 3 is a little different to the Python 2 flavor due to big changes between the two different versions of the language. For example, in the Python 2 variant the differences between old and new style classes are covered. This loses relevance in in the Python 3 version, but there are some extra tests covering new functionality.
146
+
Content for Python 3 is a little different to the Python 2 flavor due to big
147
+
changes between the two different versions of the language. For example, in
148
+
the Python 2 variant the differences between old and new style classes are
149
+
covered. This loses relevance in in the Python 3 version, but there are some
150
+
extra tests covering new functionality.
126
151
127
152
128
153
Finding More Koan Projects
129
154
--------------------------
130
155
131
-
Right now there are a lot of spinoff Koan projects out there for a great number of languages and frameworks. Many of them do not have that much content, but contributing to them is a great way to learn. At the moment, most of them can be found by searching for 'koans' on github.
156
+
There are number of other great Koan projects out there for various languages
157
+
and frameworks. Most of them can be found in github. Also there is a little
Thanks go to Jim Weirich and Joe O'Brien for the original Ruby Koans that the Python Koans is based on! Also the Ruby Koans in turn borrows from Metakoans so thanks also go to Ara Howard for that!
169
+
Thanks go to Jim Weirich and Joe O'Brien for the original Ruby Koans that the
170
+
Python Koans is based on! Also the Ruby Koans in turn borrows from Metakoans
171
+
so thanks also go to Ara Howard for that!
154
172
155
-
Also thanks to everyone who helped with the Python Koans conversion! In particular I got a great headstart on the project by forking from this Python Koans startup project:
173
+
Also thanks to everyone who has contributed to Python Koans! I got a great
174
+
headstart by taking over a code base initiated by the combined Mikes of
175
+
FPIP. So here's a little plug for their very cool Python podcast:
0 commit comments