Skip to main content

Python exercise trainer, inspired by rustlings.

Project description

Pylings


Made with Python Python Version PyPI Downloads GitHub Stars Build Status

Purpose

Pylings is an interactive Python learning tool heavily inspired by the renowned Rustlings. It provides small, focused exercises to help you learn Python by fixing code snippets and experimenting with them.

Pylings is designed to help beginners and experienced developers alike improve their Python skills through hands-on practice. Each exercise covers core Python concepts such as variables, data structures, loops, and more. This includes reading and responding to compiler and interpreter messages!

Installation

Prerequisites

  • python >= 3.10 installed on your system
  • Git (optional, for version control)

Steps

  1. Install via pip (preferred) :

    Windows

    py -m pip install pylings
    

    Linux/Unix

    pip install pylings
    

    or use git and install locally:

    git clone git@github.com:CompEng0001/pylings.git pylings-package
    cd pylings-package
    pip install .
    

Working environment

Editor

General recommendation is VS Code with the python plugin. But any editor that supports python should be enough for working on the exercises.

Will run in GitHub Codespaces

Terminal

While working with Pylings, please use a modern terminal for the best user experience, especially we recommend the Windows Terminal, with Git Bash via VS Code.

The default terminal on Linux and Mac should be sufficient too.

[!IMPORTANT] There are some rendering issues, with Linux based terminals and some terminal multiplexers.

Doing Exercises

The exercises are sorted by topic and can be found in the subdirectory exercises/<topic>. For every topic, there is an additional README.md file with some resources to get you started on the topic.

We highly recommend that you have a look at them before you start.

Most exercises contain an error that keeps them from compiling, and it's up to you to fix it!

Some exercises contain tests that need to pass for the exercise to be done

Search for TODO to find out what you need to change. Ask for hints by entering h

Running Pylings

Once installed via pip or git, navigate to a directory of your choice and run:

<py,python3> -m pylings init

or provide the path as an argument:

<py,python3> -m pylings init --path path/to/initialise-pylings

If a directory already exists with the same name you can use:

<py,python3> -m pylings init --force [--path path/to/initialise-pylings]

Then you can launch pylings in the initialised directory

<py,python3> -m pylings

[!TIP] Of course you could always add the following to your PATH, and you call pylings directly:

  • Windows
    • $HOME/AppData/Local/Programs/Python/Python313/
  • Linux
    • $HOME/.local/bin

Commands/Arguments

Pylings v1.1.0 supports additional developer-friendly commands:

  • update [--path path/to/initialised-pylings] updates the workspace with the current version:

    • Useful after upgrading Pylings via pip install --upgrade pylings

    • Defaults to the current working directory (cwd)

    • Adds new exercises and removes obsolete ones from the workspace

  • run, starts pylings from a specific exercise:

    • pylings run exercises/01_variables/variables1.py
    • Triggers welcome message if it's your first time
  • dry-run, executes an exercise non-interactively:

    • pylings dry-run 01_variables/variables1.py
    • Accepts paths with or without the exercises/ prefix
    • Use --source workspace (default) to run from local files
    • Use --source package to run the exercise bundled with the installed Pylings package
  • reset, resets an exercise non-interactively:

    • pylings reset exercises/01_variables/variables1.py
  • sol, executes a solution file non-interactively:

    • pylings solution 01_variables/variables1.py
    • Accepts paths with or without the solutions/ prefix
    • --source package (default) uses installed Pylings files
    • --source workspace runs your own solution from the local workspace
  • --debug, enables debug logging for advanced output, log file is workspace .pylings_debug.log

  • -v, --version, displays version, license, and repository link

  • -h, --help, shows usage info for all commands

List mode

You can open an interactive list of all exercises by pressing l after launching pylings

  • See the status of all exercises (done or pending)
  • s: Continue at selected exercise, allowing you to tempoarily skipping exercises or revisitng a previous one
  • r: Resets the current selected exercise back to its pending state, live!
  • c: Checks all exercises and updates the state, incase you modify outside of pylings.

See the footer of the list for all possibilities.

Contributing

See CONTRIBUTING.md 🔗

Contributions are welcome! Feel free to open issues or submit pull requests.

License

This project is licensed under the MIT License.

Author

CompEng0001

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylings-1.1.1.tar.gz (87.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pylings-1.1.1-py3-none-any.whl (128.4 kB view details)

Uploaded Python 3

File details

Details for the file pylings-1.1.1.tar.gz.

File metadata

  • Download URL: pylings-1.1.1.tar.gz
  • Upload date:
  • Size: 87.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pylings-1.1.1.tar.gz
Algorithm Hash digest
SHA256 a880b3b05251e154a4637aeefb843dc09eb2f5121773c3c2ba6ed6abd1c65177
MD5 2b312d92a95bdf0695fc0c02fe016def
BLAKE2b-256 e52afa2b59717f0f97339eda420f5a146a2d456d5c40db93d8259b23b9fbd2a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylings-1.1.1.tar.gz:

Publisher: python-publish.yml on CompEng0001/Pylings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pylings-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: pylings-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 128.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pylings-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c95a4c209910a19c9029dd85729122d7d7f38af5ef5d7411771421f9d43a5ee5
MD5 0c90da2cdb6a739f965bf00dbb04262f
BLAKE2b-256 a0dc7c93ad660322bd8b3c39b087b383c95e77dd1fa0f805fe0b7c952dc343c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylings-1.1.1-py3-none-any.whl:

Publisher: python-publish.yml on CompEng0001/Pylings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page