[Python-ideas] Partial operator (and 'third-party methods' and 'piping') [was Re: Function composition (was no subject)]

Terry Reedy tjreedy at udel.edu
Mon May 11 19:45:35 CEST 2015


On 5/11/2015 10:41 AM, Guido van Rossum wrote:
> As long as I'm "in charge" the chances of this (or anything like it)
> being accepted into Python are zero.

I have been waiting for this response (which I agree with).
By 'this', I presume you mean either more new syntax other than '@', or 
official support of '@' other than for matrix or array multiplication.

 > I get a headache when I try to
> understand code that uses function composition,

Function composition is the *process* of using the output of one 
function (broadly speaking) as the input (or one of the inputs) of 
another function.  All python code does this.  The discussion is about 
adding a composition operator or function or notation (and 
accoutrements) as a duplicate *syntax* for expressing composition.  As I 
posted before, mathematician's usually define the operator in terms of 
call syntax, which can also express composition.

 > and I end up having to
> laboriously rewrite it using more traditional call notation before I
> move on to understanding what it actually does.

Mathematicians do rewrites also ;-).
The proof of (f @ g) @ h = f @ (g @ h) (associativity) is that
((f @ g) @ h)(x) and (f @ (g @ h))(x) can both be rewritten as
f(g(h(x))).

> I understand that it's fun to try to sole this puzzle, but evolving
> Python is more than solving puzzles.

Leaving aside the problem of stack overflow, one can rewrite "for x in 
iterable: process x" to perform the same computational process with 
recursive syntax (using iter and next and catching StopIteration).  But 
one would have to be really stuck on the recursive syntax, as opposed to 
the inductive process, to use it in practice.

-- 
Terry Jan Reedy



More information about the Python-ideas mailing list