function operators
Delaney, Timothy
tdelaney at avaya.com
Mon Nov 26 20:52:33 EST 2001
> From: James A. H. Skillen [mailto:jahs at jahs.org]
>
> Has anyone ever wished that Python had operators defined on functions?
> For example, suppose you want the function f(x) = cos(x) + sin(x).
> You could do:
>
> def f(x):
> return cos(x) + sin(x)
>
> or
>
> f = lambda x: cos(x) + sin(x)
>
> but wouldn't:
>
> f = cos + sin
>
> be *much* nicer?
You could do all of this using callable classes. Wouldn't even be
particularly difficult.
For a few pointers in the right direction, look at the currying classes at
http://aspn.activestate.com/ASPN/Python/Cookbook/.
Tim Delaney
More information about the Python-list
mailing list