Would Anonymous Functions Help in Learning Programming/Python?

Scott David Daniels Scott.Daniels at Acm.Org
Sun Sep 23 17:26:32 EDT 2007


Ron Adam wrote:
> Scott David Daniels wrote:
>> Ron Adam wrote:
>>> .... How about this?
>>> def integrate(fn, x1, x2, n=100):...
>> The point was a pedagogic suggestion, ... 
> I understood your point.  I just found it interesting since I've been 
> trying to extend my math (for use with python) skills in this area.

Ah, sorry.  I had realized I wasn't explicit in my first message.
Yes, a perfectly fine integration.

You can then (and this is a major jump to get used to):
     import functools

     Sine = functools.partial(integrate, math.cos, 0.0, n=100)

Similarly, you can define a derivative that will behave fairly well,
all without examining the definition of the function being operated
upon.

-Scott




More information about the Python-list mailing list