[Edu-sig] Wrapping functions in a Function class

Andrew Harrington aharrin at luc.edu
Wed Dec 12 17:35:23 CET 2007


Nice wrapper class Kirby!
One thought:  multiplying functions is another operation.  I would
tend to reserve '*' for that, or you will be confusing of limited.
Since the raised circle is not a python operator, it appears you need
to use a different, nonstandard composition symbol.  Perhaps '%' (it
has a raise circle as part of it :-) ).  Then have the Function class
do the basic arithmetic operations *and* composition.

On Dec 11, 2007 8:24 PM, kirby urner <kirby.urner at gmail.com> wrote:
> 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
> _______________________________________________
> Edu-sig mailing list
> Edu-sig at python.org
> http://mail.python.org/mailman/listinfo/edu-sig
>



-- 
Andrew N. Harrington
  Director of Academic Programs
  Computer Science Department
  Loyola University Chicago
  512B Lewis Towers (office)
  Snail mail to Lewis Towers 416
  820 North Michigan Avenue
  Chicago, Illinois 60611

http://www.cs.luc.edu/~anh
Phone: 312-915-7999
Fax:    312-915-7998
gdp at cs.luc.edu for graduate administration
upd at cs.luc.edu for undergrad administration
aharrin at luc.edu as professor


More information about the Edu-sig mailing list