Skip to main content

Build Status codecov Checked with mypy Codacy Badge Updates PyPI - Python Version PyPI version GitHub code size in bytes paroxython SLOC tests SLOC helpers SLOC spec features taxonomy mappings GitHub commit activity Downloads Code style: black License: MIT Band-aid

Introduction

Paroxython is a set of command line tools which tag and filter by algorithmic features your collection of Python programming exercises.

Audience

You are a teacher, in charge of an introductory programming course in an educational institution. Over the years, you have accumulated many—far too many—programs and code snippets that may be of interest to your students.

Or, as a seasoned developer, you would like to share your knowledge by helping a loved one learn how to code. A cursory search for pedagogical material yields an overwhelming amount of websites and repositories stuffed with Python programs of various levels (e.g., 1, 2, 3, 4, 5, 6, and a lot more from Awesome Python in Education).

In any case, the Python source codes you have gathered are typically numerous (hundreds or even thousands), reasonably sized (anything below 100 lines of code), and educational in nature (e.g., snippets, examples, quizzes, exercise solutions, classic algorithms). The programming concepts you plan to teach remain relatively low level (e.g. assignments, nested loops, accumulation patterns, tail recursive functions, etc.).

If all that sounds familiar, keep reading me.

Main goals

Paroxython aims to help you select, from your collection, the one program that best suits your needs. For instance, it will gladly answer the following questions:

  • How can this concept be illustrated?
  • What problems use the same algorithmic and data structures as this one?
  • What homework assignment should I give my students so they can practice the content of the last lesson?

Moreover, since Paroxython knows what your class knows, it can recommend the right program at the right time:

  • What would make a good review exercise?
  • Which exercises can I give on this exam?
  • What is the current learning cost of this example?

In the long run, Paroxython may guide you and somehow make you rethink your course outline:

  • What are the prerequisites for the concept of assignment?
  • Do I have enough material to introduce subroutines before I even talk about conditionals and loops?
  • Among the loops, which must come first: the most powerful (while), or the most useful (for)?
  • How to logically structure this bunch of usual iterative patterns?
  • What are the basics, exactly?

All issues on which the author changed his mind since he started to work on this project!

In an ideal world, Paroxython could even put an end to the deadliest religious wars, with rational, data-driven arguments:

  • Father, is it a sin to exit early?
  • Should a real byte use a mask?

How it works

Paroxython starts from a given folder of programs. Its contents is parsed, and all features that meet the provided specifications are labelled and associated with their spans (e.g., "assignment_lhs_identifier:a": 4, 6, 18 or "loop_with_late_exit:while": 3-7, 20-29).

These labels constitute only scattered knowledge. The next step is to map them onto a taxonomy designed with basic hierarchical constraints in mind (e.g., the fact that the introduction of the concept of early exit must come after that of loop, which itself requires that of control flow, is expressed by the taxon "flow/loop/exit/early").

A taxonomy.
Extract of the taxonomy generated from The Algorithms - Python.
Click to jump to its full dynamic version in the user manual.

Everything is then persisted in a tag database, which can later be filtered through a pipeline of commands, for instance:

  • include only the programs which feature a recursive function;
  • exclude this or that program you want to set aside for the exam;
  • “impart” all programs studied so far, i.e, consider that all the notions they implement are acquired.

The result is a list of program recommendations ordered by increasing learning cost.

Example

Suppose that the programs directory contains these simple programs.

First, build this tag database:

> paroxython collect programs
Labelling 21 programs.
Mapping taxonomy on 21 programs.
Writing programs_db.json.

Then, filter it through this pipeline:

> paroxython recommend programs
Processing 5 commands on 21 programs.
  19 programs remaining after operation 1 (impart).
  18 programs remaining after operation 2 (exclude).
  12 programs remaining after operation 3 (exclude).
  10 programs remaining after operation 4 (include).
  10 programs remaining after operation 5 (hide).
Dumped: programs_recommendations.md.

Et voilà, your recommendation report!

Installation and test-drive

Command line

Much to no one's surprise:

python -m pip install paroxython

The following command should print a help message and exit:

paroxython --help

For development from a checkout, use uv sync to install the project and its development dependencies, and run the tests with uv run pytest. To build a source distribution and wheel, run uv build. After checking the files in dist/, publish only the intended release, for example:

uv publish dist/paroxython-0.7.4.tar.gz dist/paroxython-0.7.4-py3-none-any.whl

IPython magic command

If you use Jupyter notebook/lab, you've also just installed a so-called magic command. Load it like this:

%load_ext paroxython

This should print "paroxython 0.7.0 loaded.". Run it on a cell of Python code:

%%paroxython                          # Lines
def fibonacci(n):                     # 2
    result = []                       # 3
    (a, b) = (0, 1)                   # 4
    while a < n:                      # 5
        result.append(a)              # 6
        (a, b) = (b, a + b)           # 7
    return result                     # 8
Taxon Lines
call/subroutine/method/sequence/list/append 6
condition/inequality 5
def/subroutine/function/impure 2-8
def/subroutine/parameter/arg 2
flow/loop/exit/late 5-7
flow/loop/while 5-7
meta/count/program/sloc/8 2-8
meta/count/subroutine/sloc/7 2-8
meta/count/variety/3 2-8
meta/program 2-8
operator/arithmetic/addition 7
style/procedural 2-8
type/number/integer/literal 4
type/number/integer/literal/zero 4
type/sequence/list 6
type/sequence/list/literal/empty 3
type/sequence/tuple/literal 4, 4, 7, 7
var/assignment/explicit/parallel 4
var/assignment/explicit/parallel/slide 7
var/assignment/explicit/single 3
var/assignment/implicit/parameter 2
var/scope/local 2-8, 2-8, 2-8, 2-8

As you can see, in this program, Paroxython identifies among others:

  • the use of the procedural paradigm (style/procedural);
  • an impure function (def/subroutine/function/impure);
  • a while loop (flow/loop/while) with a late exit (flow/loop/exit/late);
  • a little bit of voodoo on lists (type/sequence/list/literal/empty and call/subroutine/method/sequence/list/append);
  • a simple tuple assignment (var/assignment/explicit/parallel). Note that we distinguish between explicit (with =) and implicit (parameters and iteration variables) assignments;
  • a “sliding” tuple assignment (var/assignment/explicit/parallel/slide). If the denomination is unique to us, the pattern itself occurs in a number of programs: implementations of C-finite sequences with C greater than 1, Greatest Common Divisor, Quicksort, etc.
  • four local variables (var/scope/local);
  • an estimation of the variety of concepts involved (meta/count/variety/3), depending on the number of lines, features and distinct features.

The magic command %%paroxython (corresponding to the subcommand tag) only scratches the surface of the system. As shown before, to estimate the learning cost of the features and get actionable recommendations, you will need first to construct the tag database with collect, and then call recommend on a pipeline of yours.

Read them

Although this is still a work-in-progress, Paroxython should already be fairly well documented:

Finally, a battery of examples and comprehensive test coverage should help answer any remaining question.

Metadata

Release files for paroxython 0.7.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for paroxython 0.7.4
File Size Uploaded Provenance Actions
paroxython-0.7.4.tar.gz 329.9 kB Without provenance Details for paroxython-0.7.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for paroxython 0.7.4
File Interpreter ABI Platform Actions
paroxython-0.7.4-py3-none-any.whl Python 3 none any Details for paroxython-0.7.4-py3-none-any.whl

Total release size: 726.6 kB

Release files / paroxython-0.7.4.tar.gz

Download URL paroxython-0.7.4.tar.gz
Size 329.9 kB
Tags Source
SHA-256 checksum
How to use checksums
96aeabcb1fcc6ffe6937249da398f36ed08f5fc3e642f22a41a95a7e7ef65e21
BLAKE2b-256 checksum
How to use checksums
aa964450f37282aac60f1d7a0837973dc5b85fdfdb7f6dceff484e0240f701de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.3

Release files / paroxython-0.7.4-py3-none-any.whl

Download URL paroxython-0.7.4-py3-none-any.whl
Size 396.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d5f6eac9a173454889eacca0aa0875f229578c5573c14432bcd68dea66f25854
BLAKE2b-256 checksum
How to use checksums
957390dc8b3ca1c35258353cdb5fe94f5aa3b4516164548bc901c53807842349
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.3

Security for paroxython 0.7.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page