Python feature request : operator for function composition

Dustan DustanGroups at gmail.com
Mon Feb 4 11:45:43 EST 2008


On Feb 4, 10:11 am, Arnaud Delobelle <arno... at googlemail.com> wrote:
> This is nice.

Thanks.

> * I wouldn't choose '&' as the composing operator as when I read
> 'double & square' I think 'take an x, double it & square it' which is
> the wrong interpretation (perhaps << instead?).

A very good point that I didn't think about; I just blindly took the
OP's chosen operator. Another thing I realized after writing this was
that I could have also written a corresponding __rand__ method
(__rlshift__ with your alternative operator), in case the object to
the right of the operator is a composer object and to the left is a
simple function.

> * I would call the decorator 'composable'.

The thing about that, though, is that this can also be used as a
composition in function style. However, I can't think of any name that
encompasses both uses. And you're right in that composer wasn't a very
good choice of name. As I say, it was written in haste.



More information about the Python-list mailing list