[Python-ideas] Dollar operator suggestion

Nick Coghlan ncoghlan at gmail.com
Fri Oct 27 00:51:42 EDT 2017

On 27 October 2017 at 02:23, Chris Barker <chris.barker at noaa.gov> wrote:

> On Thu, Oct 26, 2017 at 6:32 AM, Paul Moore <p.f.moore at gmail.com> wrote:
>> Procedural languages, and Python in particular, simply don't work like
>> that. Functions have arbitrary numbers of arguments,
> And can return an arbitrary number of values. OK, technically a single
> tuple of values, but that does complicate the whole simple chaining thing.
> In short -- Python is not a functional language, even though is supports a
> number of functional idioms.

https://bugs.python.org/issue1506122 has a brief discussion of the
non-syntactic variant of this proposal:

    functools.compose(len, set, str)(foo) => -> len(set(str(foo)))

The main concerns that resulted in the suggestion being rejected are:

* it isn't clear to folks that aren't already familiar with FP why the call
order for the composed functions should be right to left
* it isn't clear why every function other than the rightmost one must
accept a single positional arg
* it isn't clear why every function other than the leftmost one must return
a single result

And it doesn't make sense to provide something more general, because if
you're writing genuinely functional code, you do tend to abide by those

So given that our position is "We don't even want to add this to the
standard library, because the learning curve for using it successfully is
too steep", it's even less likely we'd be willing to add syntax for the

By contrast, "FP-for-Python" libraries like toolz [1] can make familiarity
with those kinds of concepts and a willingness to abide by the related
conventions a pre-requisite for using them. It's just opt-in, the same way
that learning to define your own classes (rather than importing existing
ones defined elsewhere) is opt-in.


[1] https://toolz.readthedocs.io/en/latest/

Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20171027/52e6c306/attachment.html>

More information about the Python-ideas mailing list