I\'ve tried to implement function composition with nice syntax and here is what I\'ve got:
from functools import partial
class _compfunc(partial):
def __lsh
append
does in-place addition, as Ignacio Vazquez-Abrams said (well, implied) -- so, while you could fix that by just adding a return
to your function, it would have the side-effect of changing the argument it was passed, too:
@composable
def f4(a):
a.append(0)
return a
It would be best to use the following even more concise code which also creates and returns a new object:
@composable
def f4(a):
return a + [0]