[Python-ideas] A more readable way to nest functions

Ed Kellett edk141 at gmail.com
Sat Jan 28 07:41:24 EST 2017


On Fri, 27 Jan 2017 at 21:29 Ethan Furman <ethan at stoneleaf.us> wrote:

On 01/27/2017 01:07 PM, Brent Brinkley wrote:
> Suggested structure:
>
>   print() <| some_func() <| another_func("Hello")

My first question is what does this look like when print() and some_func()
have other parameters?  In other words, what would this look like?

     print('hello', name, some_func('whatsit', another_func('good-bye')),
sep=' .-. ')


This idea doesn't solve the general problem well, but I'm not convinced
that it needs to; that can be addressed by making partial function
application syntax nicer. Although I think it's probably fairly useful
anyway.

FWIW, I'd spell it without the (), so it's simply a right-associative
binary operator on expressions, (a -> b, a) -> b, rather than magic syntax.

    print XYZ some_func XYZ another_func("Hello")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170128/00ccb19b/attachment.html>


More information about the Python-ideas mailing list