On Sun, May 24, 2020 at 4:55 PM David Mertz <me...@gnosis.cx> wrote:

> Changed subject line. This is far from original topic.
>
> On Sun, May 24, 2020, 9:35 AM Ram Rachum <r...@rachum.com> wrote:
>
>> What's wrong with using @? If I understand correctly, it's used for
>> matrix multiplication, which is far enough from function composition to
>> avoid confusion. And it's slightly similar visually to a circle.
>>
>
> I like @. Function composition is kinda-sorta enough like for product that
> I can even make sense of the same operator.
>
> But how would you go about getting a .__matmul__ attribute onto all
> functions.
>

That's easy, especially when everyone is talking about evil.

```
from forbiddenfruit import curse

def compose(self, other):
return lambda *args, **kwargs: self(other (*args, **kwargs))

for func in [compose, len]:
curse(type(func), "__matmul__", compose)

assert (len @ str)(789) == 3

```

https://repl.it/@alexmojaki/LeanEnergeticPublisher#main.py

But seriously, I don't see that much point to this idea. It's just slightly
more concise while not being particularly readable or beginner friendly.

```
sorted(paths, key=len @ str)
sorted(paths, key=lambda p: len(str(p)))
```

I think the problem is just that lambda isn't the nicest syntax, and we'd
like something more concise, e.g.

```
sorted(paths, key=:len(str($)))
```

which would be more generally useful. But I know this kind of thing has
been discussed to death.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/LQX2GXNTTKHDM7MPNKXKLHPN7QECKZJA/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to