Package: paroxython
IntroductionParoxython is a set of command line tools whichtagandfilterby algorithmic features your collection of Python programming exercises.AudienceYou 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 fromAwesome Python in Education).In any case, the Python source codes you have gathered are typicallynumerous(hundreds or even thousands),reasonably sized(anything below 100 lines of code),
andeducationalin nature (e.g., snippets, examples, quizzes, exercise solutions, classic algorithms).
The programming concepts you plan to teach remain relativelylow level(e.g. assignments, nested loops, accumulation patterns, tail recursive functions, etc.).If all that sounds familiar, keep reading me.Main goalsParoxython 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 thebasics, 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 worksParoxython starts from a given folder ofprograms. Its contents is parsed, and all features that meet the providedspecificationsare labelled and associated with their spans (e.g.,"assignment_lhs_identifier:a": 4, 6, 18or"loop_with_late_exit:while": 3-7, 20-29).Theselabelsconstitute only scattered knowledge. The next step is to map them onto ataxonomydesigned 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 thetaxon"flow/loop/exit/early").Extract of the taxonomy generated fromThe Algorithms - Python.Click to jump to its full dynamic version in the user manual.Everything is then persisted in a tagdatabase, which can later be filtered through apipelineof commands, for instance:includeonly the programs which feature a recursive function;excludethis 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 programrecommendationsordered by increasing learning cost.ExampleSuppose that theprogramsdirectory containsthese simple programs.First, buildthis tag database:>paroxythoncollectprograms
Labelling21programs.
Mappingtaxonomyon21programs.
Writingprograms_db.json.Then, filter it throughthis pipeline:>paroxythonrecommendprograms
Processing5commandson21programs.19programsremainingafteroperation1(impart).18programsremainingafteroperation2(exclude).12programsremainingafteroperation3(exclude).10programsremainingafteroperation4(include).10programsremainingafteroperation5(hide).
Dumped:programs_recommendations.md.Et voilà,your recommendation report!Installation and test-driveCommand lineMuch to no one's surprise:python -m pip install paroxythonThe following command should print a help message and exit:paroxython --helpIPython magic commandIf you use Jupyter notebook/lab, you've also just installed a so-called magic command. Load it like this:%load_extparoxythonThis should print"paroxython 0.7.0 loaded.". Run it on a cell of Python code:%%paroxython# Linesdeffibonacci(n):# 2result=[]# 3(a,b)=(0,1)# 4whilea<n:# 5result.append(a)# 6(a,b)=(b,a+b)# 7returnresult# 8TaxonLinescall/subroutine/method/sequence/list/append6condition/inequality5def/subroutine/function/impure2-8def/subroutine/parameter/arg2flow/loop/exit/late5-7flow/loop/while5-7meta/count/program/sloc/82-8meta/count/subroutine/sloc/72-8meta/count/variety/32-8meta/program2-8operator/arithmetic/addition7style/procedural2-8type/number/integer/literal4type/number/integer/literal/zero4type/sequence/list6type/sequence/list/literal/empty3type/sequence/tuple/literal4, 4, 7, 7var/assignment/explicit/parallel4var/assignment/explicit/parallel/slide7var/assignment/explicit/single3var/assignment/implicit/parameter2var/scope/local2-8, 2-8, 2-8, 2-8As you can see, in this program, Paroxython identifies among others:the use of theprocedural paradigm(style/procedural);an impure function(def/subroutine/function/impure);awhileloop (flow/loop/while) with a late exit (flow/loop/exit/late);a little bit of voodoo on lists (type/sequence/list/literal/emptyandcall/subroutine/method/sequence/list/append);a simpletuple 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 ofC-finite sequenceswith 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/***), depending on the number of lines, features and distinct features.The magic command%%paroxython(corresponding to the subcommandtag) 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 withcollect, and then callrecommendon a pipeline of yours.Read themAlthough this is still a work-in-progress, Paroxython should already be fairly welldocumented:User manual:write a command pipeline to get recommendations,prepare your program collections for better results,understand and modify the taxonomic classification,and more.Developer manual:get a rough idea of the program structure and operations,use the provided helpers to contribute to the code,and more.Module reference.Feature specifications: a document mixing prose, tests, regular expressions and SQL queries to describe which algorithmic features are recognized and how.User types: all objects of interest are precisely typed and checked bymypy.Finally, abattery of examplesandcomprehensive test coverageshould help answer any remaining question.