[Edu-sig] welcome to algebra city!

kirby urner kirby.urner at gmail.com
Thu Mar 17 10:03:02 EDT 2016


One of my mainstays, when it comes to teaching Python, is the Composable
class.

I worked on this Python type with Steve Holden back in the day, when he was
writing his four part Python curriculum for O'Reilly School of Technology.

His version of Composable shows up in Chapter One of the fourth course:

http://archive.oreilly.com/oreillyschool/courses/Python4/Python4-01.html#s_03

My current version of the Composer class, used as recently as last night in
my Session 8-of-10 for Saisoft.net, is embedded in this Jupyter Notebook,
which should render in any browser:

http://nbviewer.jupyter.org/github/4dsolutions/Python5/blob/master/ComposingFunctions.ipynb

The usefulness of the Composer class is multifaceted:

*  It demonstrates operator overloading, providing meaning / behavior for
both __mul__ and __pow__.

* Algebraically, composition is a basic operation and relates to "piping"
in the bash shell.  Composing functions is core to lambda calculus. [1]

When the output of a first function becomes the input to a next, that's
composition.

Example:

$ ls *.py | wc -l

which outputs the number of Python source code modules in a given
directory.  Notice how the pipe operator is used to get output from the
command on the left to the command on the right.

* Finally, Composable is usable as a class decorator, turning the decorated
function into a composable one.

So introducing composition of functions is an excuse to learn / reinforce
many Python concepts.

Kirby

[1]  per previous posts, whereas lambda calc is a highly specialized
subject, if repurposed to contrast with delta calc i.e. conventional
calculus, it becomes a marketing / publishing term for the kind of discrete
math / compsci that states are starting to mandate.  As a high schooler
taking algebra, you might want to continue with more lambda than delta
calc, depending on career plans.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edu-sig/attachments/20160317/aaa324df/attachment.html>


More information about the Edu-sig mailing list