[Edu-sig] Wrapping functions in a Function class

kirby urner kirby.urner at gmail.com
Wed Dec 12 03:24:58 CET 2007


Got a green light for my talk @ Pycon, meaning I'll be doing a quick
run through some group theory stuff, as we teach pre-college in our
prototype Pythonic Math Class of the Future (what the talk is about).

Here's a pertainent link:
http://mail.geneseo.edu/pipermail/math-thinking-l/2007-November/001211.html

Note this idiom of using a decorator to wrap a function as a class
object, with __call__ made to pass through an argument for evaluation
(like it were still just a regular function) and __mul__ made to make
functions "composable" i.e. "objects that multiply" (our motive for
wrapping functions within objects in the first place i.e. to make use
of Python's special names, __mul__ in particular).

Kirby


More information about the Edu-sig mailing list