Back to the notes

PyLings borrows Rustlings' exercise format for Python

A new Python learning tool takes the test-driven approach from Rust's Rustlings and applies it to Python fundamentals.

Python source code displayed on a computer monitor
Chris Ried / Unsplash Unsplash License

Someone built PyLings, a Python learning tool that copies the Rustlings format. You fix broken code snippets to make the tests pass. Each exercise isolates one concept. The interesting bit is the format choice. Rustlings works because Rust forces you to think about ownership and types before the compiler lets you run anything. Python does not have that forcing function. You can write broken logic and it will execute until it hits the broken line. PyLings tries to replicate the structure without the compiler. The exercises include failing tests and you edit the code until the tests turn green. It is test-driven learning, which matches how I actually write Python at work. You write the test first, then make it pass. The repo has exercises on basics like variables, functions, control flow, and data structures. Nothing on decorators or async yet. The format could work well for those topics because they are where Python beginners get stuck. Decorators especially; the syntax looks simple until you try to write one that takes arguments. I would have added a watch mode that reruns tests on file save. The manual feedback loop of edit then run slows down the muscle memory part of learning. Rustlings has this. You save the file and the output updates immediately. The other missing piece is progression tracking. Rustlings shows you a completion percentage and suggests the next exercise. PyLings just has a list of files. Small detail but it matters when you are grinding through fifty exercises and need to see the progress bar move. Still, the core idea holds. Test-driven exercises beat reading documentation. You learn faster when the feedback is immediate and the scope is narrow. PyLings gives you that for Python without needing to set up pytest yourself.


Source: PyLings: Solve Exercises and Learn Python

Back to all notes

Behind the notes

Vikrant
Sharma.

Artificial Intelligence Engineer intern at Voxon Photonics in Adelaide. Studying a Master of Information and Communications Technology at UniSC, with a focus on data, machine learning and security.

Meet the person behind the work