{"id":13523909,"url":"https://github.com/gregmalcolm/python_koans","last_synced_at":"2025-05-14T01:07:10.559Z","repository":{"id":826311,"uuid":"541456","full_name":"gregmalcolm/python_koans","owner":"gregmalcolm","description":"Python Koans - Learn Python through TDD","archived":false,"fork":false,"pushed_at":"2024-08-18T20:33:41.000Z","size":576,"stargazers_count":4979,"open_issues_count":21,"forks_count":2840,"subscribers_count":289,"default_branch":"master","last_synced_at":"2025-04-01T21:16:35.657Z","etag":null,"topics":["koans","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gregmalcolm.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-03-01T17:04:31.000Z","updated_at":"2025-03-31T16:12:38.000Z","dependencies_parsed_at":"2024-12-09T23:12:15.114Z","dependency_job_id":"5dfb3224-6057-4244-b973-c09771b577d7","html_url":"https://github.com/gregmalcolm/python_koans","commit_stats":{"total_commits":288,"total_committers":96,"mean_commits":3.0,"dds":0.6875,"last_synced_commit":"d797352b991722d309aec69cd87aa3805a4bdde3"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregmalcolm%2Fpython_koans","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregmalcolm%2Fpython_koans/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregmalcolm%2Fpython_koans/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregmalcolm%2Fpython_koans/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gregmalcolm","download_url":"https://codeload.github.com/gregmalcolm/python_koans/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247934841,"owners_count":21020729,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["koans","python"],"created_at":"2024-08-01T06:01:05.006Z","updated_at":"2025-04-08T22:19:08.862Z","avatar_url":"https://github.com/gregmalcolm.png","language":"Python","readme":"============\nPython Koans\n============\n\n.. image:: https://travis-ci.org/gregmalcolm/python_koans.png?branch=master\n   :target: http://travis-ci.org/gregmalcolm/python_koans\n\n.. image:: https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod\n    :target: https://gitpod.io/#https://github.com/gregmalcolm/python_koans\n    \n.. image:: https://www.eclipse.org/che/contribute.svg\n    :target: https://workspaces.openshift.com/f?url=https://gitpod.io/#https://github.com/gregmalcolm/python_koans\n\nOne click installation:\n-----------------------\n\n.. image:: https://www.eclipse.org/che/contribute.svg\n    :target: https://workspaces.openshift.com/f?url=https://gitpod.io/#https://github.com/gregmalcolm/python_koans\n|   or\n.. image:: https://gitpod.io/button/open-in-gitpod.svg\n    :target: https://gitpod.io/#https://gitpod.io/#https://github.com/gregmalcolm/python_koans\n\n|\n\nPython Koans is a port of Edgecase's \"Ruby Koans\" which can be found\nat http://rubykoans.com/.\n\n.. image:: https://user-images.githubusercontent.com/2614930/28401740-ec6214b2-6cd0-11e7-8afd-30ed3102bfd6.png\n\nPython Koans is an interactive tutorial for learning the Python programming\nlanguage by making tests pass.\n\nMost tests are *fixed* by filling the missing parts of assert functions. Eg:\n\n.. code-block:: python\n\n    self.assertEqual(__, 1+2)\n\nwhich can be fixed by replacing the __ part with the appropriate code:\n\n.. code-block:: python\n\n    self.assertEqual(3, 1+2)\n\nOccasionally you will encounter some failing tests that are already filled out.\nIn these cases you will need to finish implementing some code to progress. For\nexample, there is an exercise for writing some code that will tell you if a\ntriangle is equilateral, isosceles or scalene.\n\nAs well as being a great way to learn some Python, it is also a good way to get\na taste of Test Driven Development (TDD).\n\n\nDownloading Python Koans\n------------------------\n\nPython Koans is available on GitHub:\n\n* https://github.com/gregmalcolm/python_koans\n\nYou can clone with Git or download the source as a zip/gz/bz2.\n\n\nInstalling Python Koans\n-----------------------\n\nAside from downloading or checking out the latest version of Python Koans, you\nneed to install the Python interpreter.\n\nAt this time of writing, we support Python 3. The policy is to try to keep\ncurrent with the latest production version.\n\nYou should be able to work with newer Python versions, but older ones will\nlikely give you problems.\n\nYou can download Python from here:\n\n* https://www.python.org/downloads/\n\nAfter installing Python make sure the folder containing the python executable\nis in the system path. In other words, you need to be able to run Python from a\ncommand console. It will either be ``python3`` or for Windows it will be ``python.exe``.\n\nIf you have problems, this may help:\n\n* https://www.python.org/about/gettingstarted/\n\nWindows users may also want to update the line in the batch file ``run.bat`` to\nset the python path::\n\n    SET PYTHON_PATH=C:\\Python39\n\n\nGetting Started\n---------------\n\nJake Hebbert has created a couple of screencasts available here:\n\nhttps://www.youtube.com/watch?v=e2WXgXEjbHY\u0026list=PL5Up_u-XkWgNcunP_UrTJG_3EXgbK2BQJ\u0026index=1\n\nOr if you prefer to read:\n\nFrom a \\*nix terminal or Windows command prompt run::\n\n.. code-block:: sh\n\n    python contemplate_koans.py\n\nor:\n\n.. code-block:: sh\n\n    python3 contemplate_koans.py\n\nIn my case I'm using Python 3 with Windows, so I fire up my command\nshell (cmd.exe) and run this:\n\n.. image:: https://user-images.githubusercontent.com/2614930/28401747-f723ff00-6cd0-11e7-9b9a-a6993b753cf6.png\n\nApparently a test failed::\n\n    AssertionError: False is not True\n\nIt also tells me exactly where the problem is, it's an assert on line 12\nof ``.\\\\koans\\\\about_asserts.py``. This one is easy, just change ``False`` to ``True`` to\nmake the test pass.\n\nSooner or later you will likely encounter tests where you are not sure what the\nexpected value should be. For example:\n\n.. code-block:: python\n\n    class Dog:\n        pass\n\n    def test_objects_are_objects(self):\n        fido = self.Dog()\n        self.assertEqual(__, isinstance(fido, object))\n\nThis is where the Python Command Line can come in handy. In this case I can\nfire up the command line, recreate the scenario and run queries:\n\n.. image:: https://user-images.githubusercontent.com/2614930/28401750-f9dcb296-6cd0-11e7-98eb-c20318eada33.png\n\nSniffer Support\n---------------\n\nSniffer allows you to run the tests continuously. If you modify any files files\nin the koans directory, it will rerun the tests.\n\nTo set this up, you need to install sniffer:\n\n.. code-block:: sh\n\n    python3 -m pip install sniffer\n\nYou should also run one of these libraries depending on your system. This will\nautomatically trigger sniffer when a file changes, otherwise sniffer will have\nto poll to see if the files have changed.\n\nOn Linux:\n\n.. code-block:: sh\n\n    python3 -m pip install pyinotify\n\nOn Windows:\n\n.. code-block:: sh\n\n    python3 -m pip install pywin32\n\n    Also available here:\n\n    https://github.com/mhammond/pywin32/releases\n\nOn macOS:\n\n.. code-block:: sh\n\n    python3 -m pip install MacFSEvents\n\nOnce it is set up, you just run:\n\n.. code-block:: sh\n\n    sniffer\n\nJust modify one of the koans files and you'll see that the tests are triggered\nautomatically. Sniffer is controlled by ``scent.py``.\n\nGetting the Most From the Koans\n-------------------------------\n\nQuoting the Ruby Koans instructions:\n\n\t\"In test-driven development the mantra has always been, red, green,\n\trefactor. Write a failing test and run it (red), make the test pass\n\t(green), then refactor it (that is look at the code and see if you\n\tcan make it any better). In this case you will need to run the koan\n\tand see it fail (red), make the test pass (green), then take a\n\tmoment and reflect upon the test to see what it is teaching you\n\tand improve the code to better communicate its intent (refactor).\"\n\n\n\nFinding More Koan Projects\n--------------------------\n\nThere are number of other great Koan projects out there for various languages\nand frameworks. Most of them can be found in GitHub. Also there is a little\nkoans activity on Bitbucket.\n\n* GitHub koan projects:\n    https://github.com/search?q=koans\u0026ref=cmdform\n\n* Bitbucket koan projects:\n    https://bitbucket.org/repo/all?name=koans\n\nTranslations\n------------\n\nTranslations are always welcome! Feel free to add one to this README\nif you happen to work on one:\n\nhttps://github.com/mswell/python_koans_br\n\nAcknowledgments\n---------------\n\nThanks go to Jim Weirich and Joe O'Brien for the original Ruby Koans that the\nPython Koans is based on! Also the Ruby Koans in turn borrows from Metakoans\nso thanks also go to Ara Howard for that!\n\nAlso thanks to everyone who has contributed to Python Koans! I got a great\nheadstart by taking over a code base initiated by the combined Mikes of\nFPIP. So here's a little plug for their very cool Python podcast:\n\n* https://www.frompythonimportpodcast.com/\n\nA big thanks also to Mike Pirnat @pirnat and Kevin Chase @kjc have pitched in\nas co-maintainers at various times\n","funding_links":[],"categories":["Languages","Python","学习资源","练习和游戏","Beginner's Delight"],"sub_categories":["Python","Python资源","介绍和教程"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregmalcolm%2Fpython_koans","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgregmalcolm%2Fpython_koans","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregmalcolm%2Fpython_koans/lists"}