Heyy, it's funcoperators idea ! >>> [1,2,3].append(4)::sort()::max() +1
[1, 2, 3] |append(4) |to(sorted) |to(max) |to(plus1) You just have to : pip install funcoperators from funcoperators import postfix as to plus1 = postfix(lambda x: x+1) from funcoperators import postfix def append(x): return postfix(lambda L: L + [x]) The module also propose a way to have infix operators, so if you want to have the "::" operator that have the same precedence than "/", you could call it "/ddot/" and do : [1,2,3] /ddot/ append(4) /ddot/ sort /ddot/ max +1 But for your case (creating Bash like "pipes" the above solution seems better). https://pypi.org/project/funcoperators/ PS: you could create "modify and return" version of "append" or "sort" like this : def append(x): @postfix def new(L): L.append(x) return L return new Then you'd have : >>> a = [1,2,3] >>> b = a |append(5) |append(6) >>> a is b True
_______________________________________________ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
