Multiparadigm Programming
with Python (PyMPP)
Chapter Index
H. Conrad Cunningham
20 April 2022
Browser Advisory: The HTML version of this textbook requires a browser that supports the display of MathML. A good choice as of April 2022 is a recent version of Firefox from Mozilla.
TODO
TODO
TODO
I plan for this chapter to use Python Rational Arithmetic modules smilar to those below. Testing will be both manual and using PyTest.
Develop new chapter similar to Chapter 12, Testing Haskell Programs, from Exploring Languages with Interpreters and Functional Programming (ELIFP):
HTML Slides: None yet
Python source code for Rational Arithmetic case study:
Module ration_rep (RatRep) — abstract base class for rational number representation
Module rational_core (RatRep subclass RatCore) — relatively prime integer tuple (i.e., compute GCD on creation)
Module rational_defer (RatRep subclass RatDefer) — integer tuple not relatively prime (i.e., defer computing GCD until value required)
Module rational_test (manual black box test script) tests both representations
Module test_rational_core (PyTest black box test script for Rat/RatCore) uses parameterized function tests
Module test_rational_defer (PyTest black box test script for Rat/RatDefer) uses parameterized function tests
Module test_rational (PyTest black box test script for Rat with both RatRep) also uses parameterized fixture
TODO: Given most of these examples use a functional programming approach, not many have been developed yet in Python.
This document also examines implementations in Scala, Elixir, Lua, Racket Scheme, and Elm.
We discuss Python implementations of a CookieJar abstract data type (ADT) in the following possible future chapter.
This document also examines implementations of this ADT in Scala and Ruby.
We discuss several Python implementations of Fowler’s internal (and one external) Lair Domain-Specific Languages (DSL) in the following Notes on Domain-Specific Languages index page.
This document also examines implementations of these DSLs in Lua—as well as Fowler’s original Ruby code.
For my Spring 2018, Python-based offering of CSci 658 (Software Language Engineering), I drafted the three-chapter booklet Python 3 Metaprogramming [4]. This booklet was inspired by David Beazley’s Python 3 Metaprogramming tutorial slides from PyCon’2013 [2]. (Beazley’s tutorial draws on material from his and Brian K. Jones’ book Python Cookbook [3].) I adapted and extended the material from Beazley’s terse slides to answer questions I had as a person relatively new to Python—or that I expected my students might have.
In Fall 2018, I continued to develop this material for my Python-based offering of CSci 556 (Multiparadigm Programming). I divided the previous booklet into chapters 5-9 of Multiparadigm Programming in Python 3. The Spring 2018 work used Python 3.6, but the Fall 2018 work used some Python 3.7 features.
This new document sought to be compatible with the concepts, terminology, and approach of my in-progress textbook Exploring Languages with Interpreters and Functional Programming [5], in particular of Chapters 2, 3, 5, 6, 7, and 11.
I retired from the full-time faculty in May 2019. As one of my post-retirement projects, I am continuing work on possible textbooks based on the course materials I had developed during my three decades as a faculty member. In January 2022, I began refining the existing content, integrating separately developed matreials together, reformatting the documents, constructing a unified bibliography (e.g., using citeproc), and improving my build workflow and use of Pandoc. I adapted this index page from a portions of my Fall 2018 CSci 556 and Spring 2019 CSci 555 course notes pages.
For the 2022 version of this work, I changed most references to “Python 3” to just be “Python”. Official support for Python 2 has now been dropped.
I maintain this chapter as text in Pandoc’s dialect of Markdown using embedded LaTeX markup for the mathematical formulas and then translate the document to HTML, PDF, and other forms as needed.