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

Ed Kellett edk141 at gmail.com
Sat Jan 28 11:37:09 EST 2017


On Sat, 28 Jan 2017 at 14:27 zmo via Python-ideas <python-ideas at python.org>
wrote:

> I agree this would look a bit more elegant. To focus on the feature of
> that operator, instead of how to write it, I'll use XYZ instead of <| in
> this post.


My thoughts exactly :)


> So, considering it's decided that the RHS is in charge of filling up all
> the arguments of the LHS, how to deal with positional and keyword
> arguments without introducing new syntax?
>

My instinct is that we don't need to deal with that; that's what partial
application is for. To be fair, I'd advocate better syntax for that, but
it's another issue.


> anyway, I guess it's pretty safe to assume that if fn_b() returns a
> scalar, it'll be easy to assume it's just a single positional argument.
>
> >     print XYZ some_func XYZ another_func("Hello")
>
> [...]
>
> Meaning that the above could also be written as:
>
>     print XYZ some_func XYZ another_func XYZ "Hello"


That looks good to me, but I think another_func("Hello") is the better one
to recommend. I think it makes it slightly more obvious what is going on.


> Then the basic operator definition could be done with a dunder
> looking like: [...]


I think the special-casiness here is unfortunate and would cause problems.
a(b()) doesn't randomly pass kwargs to a if b happens to return a certain
kind of thing.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170128/d72b996e/attachment-0001.html>


More information about the Python-ideas mailing list